package cn.fl.warrant.controller;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSONObject;

import cmm.comm.facade.framework.api.ISysDictionaryApiService;
import cmm.comm.facade.framework.dto.SysDictionaryDTO;
import cmm.comm.facade.upload.api.IUploadApiService;
import cmm.comm.facade.upload.condition.SysUlFilesRecQueryCondition;
import cmm.comm.facade.upload.constant.SysUlFilesRecConstant;
import cmm.comm.facade.upload.constant.UploadConstant;
import cmm.comm.facade.upload.dto.SysUlFilesRecDTO;
import cmm.mid.core.framework.dto.DataResultDTO;
import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.user.facade.system.api.ISysOrgApiService;
import cmm.user.facade.system.api.ISysUsrApiService;
import cmm.user.facade.system.condition.SysUsrQueryCondition;
import cmm.user.facade.system.dto.SysOrgDTO;
import cmm.user.facade.system.dto.SysUsrDTO;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.DateUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.cmm.cache.framework.utils.PropertiesCacheUtils;
import cn.fl.customer.service.ICstBscInfoService;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.mcr.api.IMcrCstCrLimApiService;
import cn.fl.project.condition.PrjPrdDtlQueryCondition;
import cn.fl.project.dto.PrjPrdDtlDTO;
import cn.fl.project.service.IPrjPrdLicInfoService;
import cn.fl.project.service.IProjectApiService;
import cn.fl.project.vo.PrjPrdLicInfoVO;
import cn.fl.system.constant.SysLogConstant;
import cn.fl.system.service.ISysUlFilesRecService;
import cn.fl.system.vo.SysUlFilesRecVO;
import cn.fl.warrant.service.IArcBorrowMainService;
import cn.fl.warrant.service.IArcBscInfoService;
import cn.fl.warrant.service.IArcMgrDetailService;
import cn.fl.warrant.service.IArcMgrMainService;
import cn.fl.warrant.service.IArcPostInfoService;
import cn.fl.warrant.service.IArcReceiptMainService;
import cn.fl.warrant.service.IArcTransferDetailService;
import cn.fl.warrant.service.IArcTransferMainService;
import cn.fl.warrant.transform.ArcReceiptDetailVOTransform;
import cn.fl.warrant.transform.ArcTransferMainVOTransform;
import cn.fl.warrant.utils.JsonUtil;
import cn.fl.warrant.vo.ArcBscInfoVO;
import cn.fl.warrant.vo.ArcMgrDetailVO;
import cn.fl.warrant.vo.ArcMgrMainVO;
import cn.fl.warrant.vo.ArcPostInfoVO;
import cn.fl.warrant.vo.ArcReceiptDetailVO;
import cn.fl.warrant.vo.ArcReceiptMainVO;
import cn.fl.warrant.vo.ArcSysFlowSHVO;
import cn.fl.warrant.vo.ArcTransferDetailVO;
import cn.fl.warrant.vo.ArcTransferMainVO;
import fl.flow.facade.flow.constant.FlowConstant;
import fl.flow.facade.flow.dto.FlowStartParamsDTO;
import fl.flow.facade.flow.dto.FlowStartedDTO;
import fl.warrant.facade.archive.api.IArcLocalContractUserApiService;
import fl.warrant.facade.archive.condition.ArcLocalContractUserQC;
import fl.warrant.facade.archive.condition.ArcMgrDetailQC;
import fl.warrant.facade.archive.condition.ArcMgrMainQC;
import fl.warrant.facade.archive.condition.ArcPostInfoQC;
import fl.warrant.facade.archive.condition.ArcReceiptDetailQueryCondition;
import fl.warrant.facade.archive.condition.ArcReceiptMainQueryCondition;
import fl.warrant.facade.archive.condition.ArcTransferDetailQueryCondition;
import fl.warrant.facade.archive.condition.ArcTransferMainQueryCondition;
import fl.warrant.facade.archive.constant.ArchiveConstants;
import fl.warrant.facade.archive.dto.ArcLocalContractUserDTO;
import fl.warrant.facade.archive.dto.ArcTransferMainDTO;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import net.sf.json.JSONArray;

/**
 * @Description: 结清移交 控制层
 */
@Controller
@RequestMapping("/archive/arcTransferMain")
public class ArcTransferMainController extends BaseController {

	private static final Logger logger = LoggerFactory.getLogger(ArcTransferMainController.class);
	
	
	@Autowired
	private IArcTransferMainService arcTransferMainService;//结清移交
	@Autowired
	private IArcTransferDetailService arcTransferDetailService;//移交申请明细
	@Autowired
	private ICstBscInfoService cstBscInfoService;//客户
	@Autowired
	private ISysDictionaryApiService sysDictionaryApiService;//数据字典
	@Autowired
	private IArcMgrMainService arcMgrMainService;//档案管理主表
	@Autowired
	private IArcPostInfoService arcPostInfoService;//邮寄信息
	@Autowired
	private IArcMgrDetailService arcMgrDetailService;//档案明细
	@Autowired
	private IArcReceiptMainService arcReceiptMainService;//交接单
	@Autowired
	private IArcBscInfoService arcBscInfoService;
	@Autowired
	private ISysUsrApiService sysUsrApiService;
	@Autowired
	private IMcrCstCrLimApiService mcrCstCrLimApiService;
	@Autowired
	private IArcBorrowMainService arcBorrowMainService;//借阅主表
	@Autowired
    private ISysOrgApiService sysOrgApiService;// 组织机构
	@Autowired
	private ISysUlFilesRecService sysUlFilesRecService;//附件
	@Autowired
    private IUploadApiService uploadApiService;//上传
	@Autowired
    private IProjectApiService projectApiService;//项目
	/**
	 * PrjPrdLicInfo 服务层BEAN
	 */
	@Autowired
	private IPrjPrdLicInfoService prjPrdLicInfoService;
	@Autowired
	private IArcLocalContractUserApiService arcLocalContractUserService;//属地合同管理员配置表
	
	
	private Map getParms(HttpServletRequest request){
		Map map=new HashMap();
		Enumeration enu=request.getParameterNames();  
		StringBuffer sb = new StringBuffer();
		while(enu.hasMoreElements()){  
		String paraName=(String)enu.nextElement();  
			map.put(paraName, request.getParameter(paraName));
		}
		return map;
	}

	/**
	 * 跳转到列表页面
	 */
	@RequestMapping("/toListPage.do")
	public String toListPage(HttpServletRequest request, HttpServletResponse response) {
		try{
			this.setAttribute(request);
			String sysCd = CurrentThreadContext.getCurrentSysCd(); 
			String orgCd = CurrentThreadContext.getCurrentOrgCd();
			String grpCd = ArchiveConstants.PRD_STS_CD;//结清状态
			//获取结清状态
			request.setAttribute("prdStsCdList", sysDictionaryApiService.getKvList(grpCd, sysCd, orgCd));
			grpCd = ArchiveConstants.ARC007;//移交状态
			//获取移交状态
			request.setAttribute("transferStateList", sysDictionaryApiService.getKvList(grpCd, sysCd, orgCd));
			BaseLogUtils.info(logger, "toListPage", "跳转到列表页面.", CurrentThreadContext.getCurrentUserName());
		}catch(Exception e){
			BaseLogUtils.error(logger, "toListPage", CurrentThreadContext.getCurrentUserName(), e);
		}
		return "archive/arcTransferMain/arcTransferMainList";
	}

	/**
	 * 列表页面查询
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping("/initList.do")
	@ResponseBody
	public Object initList(HttpServletRequest request, HttpServletResponse response) {
		this.setAttribute(request);
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		String cstNm = request.getParameter("cstNm");
		String contractNo = request.getParameter("contractNo");
		String paySchNo = request.getParameter("paySchNo");
		String buOrgCd = request.getParameter("bussDepartment");
		String prOrgCd = request.getParameter("cstMgrOrgCd");
		String actPayTmB = request.getParameter("actPayTmB");
		String actPayTmE = request.getParameter("actPayTmE");
		String prdstscd = request.getParameter("prdstscd");
		String transferStatus = request.getParameter("transferStatus");
		String cstMgrNm = request.getParameter("cstMgrNm");
		String transferType = request.getParameter("transferType");     
		Pager page = new Pager();
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}
		if (StringUtils.isNotEmpty(pageSize)) {
			page.setEveryPage(Integer.parseInt(pageSize));
		}
		//查询条件
		ArcTransferMainQueryCondition qc=new ArcTransferMainQueryCondition();
		if (StringUtils.isNotEmpty(cstNm)) {
			qc.setCstNm(cstNm);
		}
		if (StringUtils.isNotEmpty(contractNo)) {
			qc.setContractNo(contractNo);;
		}
		if (StringUtils.isNotEmpty(paySchNo)) {
			qc.setPaySchNo(paySchNo);;
		}
		if (StringUtils.isNotEmpty(buOrgCd)) {
			qc.setBuOrgCd(buOrgCd);;
		}
		if (StringUtils.isNotEmpty(prOrgCd)) {
			qc.setPrOrgCd(prOrgCd);;
		}
		if (StringUtils.isNotEmpty(prOrgCd)) {
			qc.setCstMgrOrgCd(prOrgCd);;
		}
		if (StringUtils.isNotEmpty(actPayTmB)) {
			qc.setActPayTmB(actPayTmB);
		}
		if (StringUtils.isNotEmpty(actPayTmE)) {
			qc.setActPayTmE(actPayTmE);
		}
		if (StringUtils.isNotEmpty(prdstscd)) {
			qc.setPrdStsCd(prdstscd);
		}
		if (StringUtils.isNotEmpty(transferStatus)) {
			qc.setTransferStatus(transferStatus);;
		}
		if (StringUtils.isNotEmpty(cstMgrNm)) {
			qc.setCstMgrNm(cstMgrNm);
		}
		if(StringUtils.isNotEmpty(transferType)){
			qc.setTransferType(transferType);
		}
		//权限添加
		qc.setUsrId(CurrentThreadContext.getCurrentUserId());
		page.setCondition(qc);

		Pager pager = this.arcTransferMainService.selectListForListPage(page);
		List<ArcTransferMainVO> list = (List<ArcTransferMainVO>) pager.getResultList();
		ListPageVO<ArcTransferMainVO> listPage = new ListPageVO<ArcTransferMainVO>(list, pager.getTotalCount());
		BaseLogUtils.info(logger, "initList", "查询数据完成. DATA:" + JSONObject.toJSONString(page), CurrentThreadContext.getCurrentUserName());
		return listPage;
	}

	/**
	 * 移交申请流程页面
	 */
	@RequestMapping(value = "/toApplyTransferFlow.do", method = { RequestMethod.GET})
	public String toApplyTransferFlow(HttpServletRequest request, HttpServletResponse response) {
		try {
			
			//String id = request.getParameter("id");//档案主表id
			String paySchNo = request.getParameter("paySchNo");//支付表号
			String paySchId = request.getParameter("paySchId");//支付表id
			String contractNo = request.getParameter("contractNo");//合同号
			String isGrpBiz = request.getParameter("isGrpBiz");//是否团单
			String prdStsCd = request.getParameter("prdStsCd");//资产状态
			String bizTypCd = request.getParameter("bizTypCd");//业务类型
			String buOrgCd  = request.getParameter("buOrgCd");//事业部
			String cstNm    = request.getParameter("cstNm");//承租人名称
			String cstId    = request.getParameter("cstId");//承租人id
			
			ArcMgrMainQC qc=new ArcMgrMainQC();
//			if (StringUtils.isNotEmpty(id)) {
//				qc.setId(Long.parseLong(id));
//			}
			if (StringUtils.isNotEmpty(paySchNo)) {
				qc.setPaySchNo(paySchNo);
			}
			if (StringUtils.isNotEmpty(contractNo)) {
				qc.setContractNo(contractNo);;
			}
			List<ArcMgrMainVO> mgrList=this.arcMgrMainService.selectList(qc);
			for (int i = 0; i < mgrList.size(); i++) {
				ArcMgrMainVO vo=mgrList.get(i);
				ArcMgrDetailQC mdqc=new ArcMgrDetailQC();
				mdqc.setArcMgrMainId(vo.getId());
				List<ArcMgrDetailVO> ppList=this.arcMgrDetailService.searchList(mdqc);//支付表明细
				vo.setArcMgrDetailList(ppList);
			}
			
			String sysCd = CurrentThreadContext.getCurrentSysCd(); 
			String orgCd = CurrentThreadContext.getCurrentOrgCd();
			
			request.setAttribute("paySchNo",paySchNo);
			request.setAttribute("paySchId",paySchId);
			request.setAttribute("contractNo",contractNo);
			request.setAttribute("arcMgrMainVO",mgrList.get(0));
			request.setAttribute("prdStsCd",prdStsCd);
			request.setAttribute("isGrpBiz",isGrpBiz);	
			request.setAttribute("bizTypCd",bizTypCd);
			request.setAttribute("buOrgCd",buOrgCd);
			request.setAttribute("cstNm", cstNm);
			request.setAttribute("cstId", cstId);
			request.setAttribute("sendTypeList", this.sysDictionaryApiService.getKvList(ArchiveConstants.ARC010,sysCd,orgCd));//接收方式
			request.setAttribute("sendCompanyList", arcBscInfoService.getKvList(sysCd, orgCd, ArchiveConstants.ARC012));//邮寄公司
			BaseLogUtils.info(logger, "toApplyTransferFlow", "跳转到列表页面.", CurrentThreadContext.getCurrentUserName());

		} catch (Exception e) {
			// TODO: handle exception
			BaseLogUtils.error(logger, "toApplyTransferFlow", e.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return "archive/arcTransferMain/arcTransferApplyFlow";
		
	}
	
	
	/**
	 * 跳转到保存页面(新增和修改)
	 */
	@RequestMapping(value = "/toSave.do")
	public Object toSave(HttpServletRequest request, HttpServletResponse response) {
		this.setAttribute(request);
		String id = request.getParameter("id");
		if(StringUtils.isNotBlank(id)) {
			request.setAttribute("entity", arcTransferMainService.selectById(Long.valueOf(id)));
		}
		return "archive/arcTransferMain/arcTransferMainSave";
	}
	
	/**
	 * 新增和修改
	 */
	@RequestMapping(value = "/save.do")
	@ResponseBody
	public Object save(ArcTransferMainVO entity,HttpServletRequest request, HttpServletResponse response){
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
		try {
			if(entity.getId() == null) {//新增
				entity.setIsValid(ArchiveConstants.IS_VALID);
				entity.setIsDel(ArchiveConstants.IS_DEL);
				entity.setCrtTm(new Date());
				entity.setCrtUsrId(CurrentThreadContext.getCurrentUserId());

//				Long id = this.arcTransferMainService.add(entity);
//				result.setData(id);
			}else {//修改
				
				ArcTransferMainVO arcTransferMainVO = arcTransferMainService.selectById(entity.getId());
				if(arcTransferMainVO != null) {
//					arcTransferMainVO.setArcLevel(entity.getArcLevel());
//					arcTransferMainVO.setCfgCd(entity.getCfgCd());
//					arcTransferMainVO.setCfgDtlCd(entity.getCfgDtlCd());
//					arcTransferMainVO.setWarrantName(entity.getWarrantName());
//					arcTransferMainVO.setWarrantType(entity.getWarrantType());
					
					arcTransferMainVO.setMdfTm(new Date());
					arcTransferMainVO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
					
					this.arcTransferMainService.update(arcTransferMainVO);
					result.setInfo(SysLogConstant.LOG_CMM_UPDATE_SUCC);
				}
			}
			BaseLogUtils.info(logger, "save", "操作数据. DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "save", "操作数据失败.DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.error(logger, "save", "操作数据失败.DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	
	/**
	 * 逻辑删除
	 */
	@RequestMapping(value = "/removeById.do")
	@ResponseBody
	public DataResultVO removeById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_DELETE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			return result;
		}
		try {
			this.arcTransferMainService.removeById(Long.valueOf(id));
			BaseLogUtils.info(logger, "removeById", "删除数据.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "removeById", "删除数据失败.[id="+id+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "removeById", "删除数据失败.[id="+id+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}

		return result;
	}
	private void setAttribute(HttpServletRequest request) {
//		String sysCd = CurrentThreadContext.getCurrentSysCd(); 
//		String orgCd = CurrentThreadContext.getCurrentOrgCd();
		//客户类型
		request.setAttribute("cstTypCdList",this.cstBscInfoService.searchCstTypCdList());
		//事业部
		request.setAttribute("buOrgCdList", arcTransferMainService.getKvDescList(ArchiveConstants.BU_ORG_CD));
		//事业部组织架构集合
		request.setAttribute("OrgList", this.cstBscInfoService.searchBusinessOrgList());
	}
	/**
	 * 到流程附加页面
	 */
	@RequestMapping(value = "/getFlow.do", method = { RequestMethod.GET})
	public String getFlow(HttpServletRequest request, HttpServletResponse response) throws BaseException {
//		try {
			
			String id = request.getParameter("id");
			String flag = request.getParameter("flag");
			request.setAttribute("flag",flag);
			request.setAttribute("id",id);
			//查找申请单
			ArcTransferMainVO avo= this.arcTransferMainService.selectById(Long.valueOf(id));
			//avo.setArcApplyDetailList(aList);
			String syscd = CurrentThreadContext.getCurrentSysCd(); 
			String orgcd = CurrentThreadContext.getCurrentOrgCd();
			request.setAttribute("sendTypeList", this.sysDictionaryApiService.getKvList(ArchiveConstants.ARC010,syscd,orgcd));//接收方式
			request.setAttribute("sendCompanyList", this.sysDictionaryApiService.getKvList(ArchiveConstants.ARC012,syscd,orgcd));//接收方式
			
			//档案明细，归档表
			String paySchNo=avo.getPaySchNo();
			ArcMgrMainQC qc=new ArcMgrMainQC();
			qc.setPaySchNo(paySchNo);
			List<ArcMgrMainVO> mgrList=this.arcMgrMainService.selectList(qc);
			for (int i = 0; i < mgrList.size(); i++) {
				ArcMgrMainVO vo=mgrList.get(i);
				ArcMgrDetailQC mdqc=new ArcMgrDetailQC();
				mdqc.setArcMgrMainId(vo.getId());
				List<ArcMgrDetailVO> ppList=this.arcMgrDetailService.searchList(mdqc);//支付表明细
				vo.setArcMgrDetailList(ppList);
			}
			request.setAttribute("paySchNo",paySchNo);
			request.setAttribute("mgr",avo);
			request.setAttribute("mgrList",mgrList);
			//邮寄信息
			List<ArcPostInfoVO> plist=new ArrayList<ArcPostInfoVO>();		
			ArcPostInfoQC condition2=new ArcPostInfoQC();
			condition2.setArcAppId(Long.valueOf(id));
			plist=this.arcPostInfoService.searchList(condition2);
			//初始化
			if (plist!=null) {
				for (int i = 0; i < plist.size(); i++) {
					ArcPostInfoVO post=plist.get(i);
					
					//商助
					if ("003".equals(flag)&& "2".equals(post.getSendPorsonType())) {
						request.setAttribute("post",post);
						plist.remove(i);
						break;
					}
					//总公司邮件
					if ("006".equals(flag)&& "3".equals(post.getSendPorsonType())) {
						request.setAttribute("post",post);
						plist.remove(i);
						break;
					}
				}
			}
			request.setAttribute("plist",plist);
			
			BaseLogUtils.info(logger, "getFlow", "跳转到列表页面.", CurrentThreadContext.getCurrentUserName());

//		} catch (Exception e) {
//			// TODO: handle exception
//			BaseLogUtils.error(logger, "getFlow", e.getMessage(), CurrentThreadContext.getCurrentUserName());
//		}
		return "archive/arcTransferMain/arcTransferFlow";
		
	}
	/**
	 * 修改流程修改
	 */
	@RequestMapping(value = "/modifyFlow.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object modifyFlow(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "modifyFlow", "修改数据,主键不存在.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		String paySchNo = request.getParameter("paySchNo");
		if(StringUtils.isEmpty(paySchNo)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "modifyFlow", "修改数据,主键不存在.[paySchNo="+paySchNo+"]", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		
		try {
			Map map=this.getParms(request);
			//查找申请单
			ArcTransferMainVO avo= this.arcTransferMainService.selectById(Long.valueOf(id));
			//avo.setArcApplyDetailList(aList);
			String flag = request.getParameter("flag");
			avo.setMdfUsrId(new Long(flag));
			this.arcTransferMainService.update(avo);
			//档案明细，归档表
			ArcMgrMainQC qc=new ArcMgrMainQC();
			qc.setPaySchNo(paySchNo);
			List<ArcMgrMainVO> mgrList=this.arcMgrMainService.selectList(qc);
			for (int i = 0; i < mgrList.size(); i++) {
				ArcMgrMainVO vo=mgrList.get(i);
				ArcMgrDetailQC mdqc=new ArcMgrDetailQC();
				mdqc.setArcMgrMainId(vo.getId());
				List<ArcMgrDetailVO> ppList=this.arcMgrDetailService.searchList(mdqc);//支付表明细
				vo.setArcMgrDetailList(ppList);
				//更归档支付表明细
				for (int j = 0; j < ppList.size(); j++) {
					ArcMgrDetailVO dvo=ppList.get(j);
					if (map.get("transferCount_p_"+dvo.getId())!=null&&!"".equals(map.get("transferCount_p_"+dvo.getId()))) {
						dvo.setTransferCount(Long.valueOf(map.get("transferCount_p_"+dvo.getId()).toString().replaceAll(" ", "")));
					}else {
						dvo.setTransferCount(0L);
					}
					this.arcMgrDetailService.modify(dvo);
				}
			}
			
			//保存邮寄信息
			ArcPostInfoVO pVo=new ArcPostInfoVO();
			pVo.setArcAppId(Long.valueOf(id));
			//保存邮寄信息
			map.put("arcAppId", id);
			map.put("arcAppType", "3");
			if("003".equals(flag)){
				//省公司邮寄
				map.put("sendPorsonType", "2");
				map.put("arcAppBussType", "2");
			}else if("006".equals(flag)) {
				//总公司邮寄
				map.put("sendPorsonType", "3");
				map.put("arcAppBussType", "3");
			}
			this.arcPostInfoService.addOrUpdate(map);

			BaseLogUtils.info(logger, "modifyFlow", "修改成功.[id="+id+"] DATA:" + JSONObject.toJSONString(avo), CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "modifyFlow", "修改失败.[id="+id+"] DATA:"  + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "modifyFlow", "修改失败.[id="+id+"] DATA:"  + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	/**
	 * 到流程列表页面 回传
	 */
	@RequestMapping(value = "/getFlowHC.do", method = { RequestMethod.GET})
	public String getFlowHC(HttpServletRequest request, HttpServletResponse response) {
		try {
			
			String id = request.getParameter("id");
			String flag = request.getParameter("flag");
			request.setAttribute("flag",flag);
			request.setAttribute("id",id);
			//查找申请单
			ArcTransferMainVO avo= this.arcTransferMainService.selectById(Long.valueOf(id));
			//avo.setArcApplyDetailList(aList);
			String syscd = CurrentThreadContext.getCurrentSysCd(); 
			String orgcd = CurrentThreadContext.getCurrentOrgCd();
			request.setAttribute("sendTypeList", this.sysDictionaryApiService.getKvList(ArchiveConstants.ARC010,syscd,orgcd));//接收方式
		
			//申请单明细
			ArcTransferDetailQueryCondition dQc=new ArcTransferDetailQueryCondition();
			dQc.setArcTransferMainId(Long.valueOf(id));
			List<ArcTransferDetailVO> dList=this.arcTransferDetailService.searchList(dQc);
			request.setAttribute("dList",dList);
			//档案明细，归档表
			String paySchNo=avo.getPaySchNo();
			ArcMgrMainQC qc=new ArcMgrMainQC();
			qc.setPaySchNo(paySchNo);
			List<ArcMgrMainVO> mgrList=this.arcMgrMainService.selectList(qc);
			for (int i = 0; i < mgrList.size(); i++) {
				ArcMgrMainVO vo=mgrList.get(i);
				ArcMgrDetailQC mdqc=new ArcMgrDetailQC();
				mdqc.setArcMgrMainId(vo.getId());
				List<ArcMgrDetailVO> ppList=this.arcMgrDetailService.searchList(mdqc);//支付表明细
				if (ppList!=null) {
					//去除结清资料
					for (int j = 0; j < ppList.size(); j++) {
						ArcMgrDetailVO dvo=ppList.get(j);
						if (ArchiveConstants.FILE_FLAG_5.equals(dvo.getFileFlag())) {
								ppList.remove(dvo);
								--j;
						}
					}
				}
				vo.setArcMgrDetailList(ppList);
			}
			request.setAttribute("paySchNo",paySchNo);
			request.setAttribute("mgr",avo);
			request.setAttribute("mgrList",mgrList);
			//邮寄信息
			List<ArcPostInfoVO> plist=new ArrayList<ArcPostInfoVO>();		
			ArcPostInfoQC condition2=new ArcPostInfoQC();
			condition2.setArcAppId(Long.valueOf(id));
			plist=this.arcPostInfoService.searchList(condition2);
			
			request.setAttribute("plist",plist);
			BaseLogUtils.info(logger, "getFlow", "跳转到列表页面.", CurrentThreadContext.getCurrentUserName());

		} catch (Exception e) {
			// TODO: handle exception
			BaseLogUtils.error(logger, "getFlow", e.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return "archive/arcTransferMain/arcTransferFlowHC";
		
	}
	/**
	 * 修改流程 回传
	 */
	@RequestMapping(value = "/modifyFlowHC.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object modifyFlowHC(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "modifyFlow", "修改数据,主键不存在.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		String paySchNo = request.getParameter("paySchNo");
		if(StringUtils.isEmpty(paySchNo)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "modifyFlow", "修改数据,主键不存在.[paySchNo="+paySchNo+"]", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		
		try {
			Map map=this.getParms(request);
			//查找申请单
			ArcTransferMainVO avo= this.arcTransferMainService.selectById(Long.valueOf(id));
			//avo.setArcApplyDetailList(aList);
			String flag = request.getParameter("flag");
			avo.setMdfUsrId(new Long(flag));
			this.arcTransferMainService.update(avo);
			//申请单明细
			ArcTransferDetailQueryCondition dQc=new ArcTransferDetailQueryCondition();
			dQc.setArcTransferMainId(Long.valueOf(id));
			List<ArcTransferDetailVO> dList=this.arcTransferDetailService.searchList(dQc);
			//更新结清资料，申请单明细
			if (dList!=null) {
				for (int i = 0; i < dList.size(); i++) {
					ArcTransferDetailVO vo=dList.get(i);
					if (map.get("transferNumber_p_"+vo.getId())!=null&&!"".equals(map.get("transferNumber_p_"+vo.getId()))) {
						vo.setTransferNumber(Long.valueOf(map.get("transferNumber_p_"+vo.getId()).toString().replaceAll(" ", "")));
					}else {
						vo.setTransferNumber(0L);
					}
					this.arcTransferDetailService.modify(vo);
				}
			}

			BaseLogUtils.info(logger, "modifyFlow", "修改成功.[id="+id+"] DATA:" + JSONObject.toJSONString(avo), CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "modifyFlow", "修改失败.[id="+id+"] DATA:"  + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "modifyFlow", "修改失败.[id="+id+"] DATA:"  + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	/**
	 * 到流程列表页面
	 */
	@RequestMapping(value = "/toViewFlow.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toViewFlow(HttpServletRequest request, HttpServletResponse response) {
		String paySchNo = request.getParameter("paySchNo");
		
		ModelAndView view = new ModelAndView("archive/arcTransferMain/arcTransferFlowList");
		//根据支付表号获取移交申请
		ArcTransferMainQueryCondition qc=new ArcTransferMainQueryCondition();
		qc.setPaySchNo(paySchNo);
		Long parentId=0L;
		List<ArcTransferMainVO> list = this.arcTransferMainService.searchListByCondition(qc,CurrentThreadContext.getCurrentSysCd(),CurrentThreadContext.getCurrentOrgCd());
		if(list.size()>0 && list!=null){
			parentId=list.get(0).getParentId();
		}
		view.addObject("paySchNo", paySchNo);
	        view.addObject("parentId", parentId);
		BaseLogUtils.info(logger, "toViewFlow", "跳转到页面.[paySchNo="+paySchNo+"]", CurrentThreadContext.getCurrentUserName());
		return view;
	}
	/**
	 * 流程数据
	 * @param request
	 * @param response
	 * @return
	 * 2018年3月15日 
	 * lxb
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/initFlowList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initFlowList(HttpServletRequest request, HttpServletResponse response) {
//		String currentPage = request.getParameter("page");
//		String pageSize = request.getParameter("pagesize");
		ArcTransferMainQueryCondition qc=new ArcTransferMainQueryCondition();
		
		String paySchNo = request.getParameter("paySchNo");
		if (StringUtils.isBlank(paySchNo)) {
			return null;
		}
		qc.setPaySchNo(paySchNo);
		List<ArcSysFlowSHVO> list=this.arcTransferMainService.searchFlow(qc);
		ListPageVO<ArcSysFlowSHVO> listPage = new ListPageVO<ArcSysFlowSHVO>(list, list.size());
		BaseLogUtils.info(logger, "initFlowList", "查询数据完成. DATA:" + JSONObject.toJSONString(list), CurrentThreadContext.getCurrentUserName());
		return listPage;
	}
	/**
	 * 发起移交申请(数据保存和流程发起)
	 */
	@RequestMapping(value = "/transferApplyStart.do")
	@ResponseBody
	public Object transferApplyStart(ArcTransferMainVO entity,HttpServletRequest request){
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
		try {
			  //1、获取参数
			  String IS_GRP_BIZ = request.getParameter("IS_GRP_BIZ");//是否团单
			  String buOrgCd = request.getParameter("buOrgCd");//事业部
			  String paySchNo = request.getParameter("paySchNo");//支付表号
			  String prdStsCd = request.getParameter("prdStsCd");//资产状态
			  String bizTypCd = request.getParameter("bizTypCd");//业务类型
			  String contractNo = request.getParameter("contractNo");//合同号
			  String arcMgrMainId =request.getParameter("arcMgrMainId");//档案管理主表id
			  String cstNm    = request.getParameter("cstNm");//承租人名称
			  BaseLogUtils.info(logger, "getParameter", "操作数据. DATA:" + IS_GRP_BIZ+":"+buOrgCd+":"+":"+paySchNo+":"+":"+prdStsCd+":"+bizTypCd+"cstNm:"+cstNm, CurrentThreadContext.getCurrentUserName());

			  //2、初始化一个结清交接单
			  ArcTransferMainVO initMv =initSettleReceipt(buOrgCd, paySchNo,prdStsCd,bizTypCd,contractNo);
			  if(initMv.getArcTransferDetailList()!=null){
				  entity.setArcTransferDetailList(initMv.getArcTransferDetailList());
				  entity.setArcReceiptMainId(initMv.getArcReceiptMainId());
				  entity.setArcReceiptName(initMv.getArcReceiptName());
				  entity.setVersioni(initMv.getVersioni());
			  }else{
					BaseLogUtils.error(logger, "initSettleReceipt没找到交接单", "操作数据失败.DATA:" + JSONObject.toJSONString(paySchNo), CurrentThreadContext.getCurrentUserName());
					result.setSuccess(BaseConstant.IS_YESNO_NO);
					result.setInfo("没找到交接单");
					return result;
			  }
			  entity.setPaySchNo(paySchNo);
			  entity.setIsValid(ArchiveConstants.IS_VALID);
			  entity.setIsDel(ArchiveConstants.IS_DEL);
			  entity.setCrtTm(new Date());
			  entity.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
			  entity.setCrtUsrNa(CurrentThreadContext.getCurrentUserName());
			  entity.setCstMgrId(CurrentThreadContext.getCurrentUserId());
			  entity.setCstMgrNm(CurrentThreadContext.getCurrentUserName());
			  entity.setCstMgrOrgCd(CurrentThreadContext.getCurrentOrgCd());
			  entity.setIsGrpBiz(IS_GRP_BIZ);
			  //3、保存移交主表与移交明细表
			  Long id = this.arcTransferMainService.transferApplyStart(entity);
			  result.setData(id);
			  BaseLogUtils.info(logger, "save", "操作数据. DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
			  Map<String, Object> param=new HashMap<String, Object>();//放入流程中的参数
			  param.put("need", "0");//是否团单  1是团单 0否团单
			  if("1".equals(IS_GRP_BIZ)){
				  param.put("need", "1");  
				  param.put("IS_GRP_BIZ", "1");
			  }
			  param.put("paySchNo", paySchNo);
			  param.put("contractNo", contractNo);
			  //4、流程发起
			  result = transferApplyStartFlow(id,param,cstNm);//cstId cstNm
			  //5、ARC_MGR_MAIN 更新档案管理主表状态为移交中 MgrMainId TRANSFER_STATUS
			  ArcMgrMainVO mgr=new ArcMgrMainVO();
			  mgr.setId(Long.parseLong(arcMgrMainId));
			  mgr.setTransferStatus(ArchiveConstants.ARC_TRANSFER_ING);
			  mgr.setMdfTm(new Date());
			  mgr.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
			  arcMgrMainService.updateById(mgr);	
			
		}catch (Exception ex) {
			ex.printStackTrace();
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.error(logger, "transferApplyStart", "操作数据失败.DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	/**
	 * 初始化一个结清交接单
	 * */
	public ArcTransferMainVO  initSettleReceipt(String buOrgCd,String paySchNo,String prdStsCd,String bizTypCd,String contractNo){
		
		ArcTransferMainVO mv=new ArcTransferMainVO();
		try{
			List<ArcTransferDetailVO> detailList=new ArrayList<ArcTransferDetailVO>();
			//筛选一个交接单
			ArcReceiptMainQueryCondition rqc=new ArcReceiptMainQueryCondition();
			/*if (StringUtils.isNotBlank(buOrgCd)) {//事业部SYS0031
				rqc.setBuOrgCd(buOrgCd);
			}*/
			if (StringUtils.isNotBlank(prdStsCd)) {//资产状态（PRJ0006）
				rqc.setSettleType(prdStsCd);
			}
			/*if (StringUtils.isNotBlank(bizTypCd)) {//业务类型（PRJ0006）
				rqc.setPrjBizType(bizTypCd);;
			}*/
			/*if (StringUtils.isNotBlank(mvo.getCstTypCd())) {//客户分类（CST0001）
				rqc.setLesseeType(mvo.getCstTypCd());
			}
			if (StringUtils.isNotBlank(mvo.getCntTypCd())) {//合同签署方式PRJ0047
				rqc.setContractSign(mvo.getCntTypCd());
			}
			if (StringUtils.isNotBlank(mvo.getIsDb())) {//是否有担保人
				rqc.setGuarantee(mvo.getIsDb());
			}
			if (StringUtils.isNotBlank(mvo.getCstTypCd2())) {//多个担保人类型
				rqc.setGuaranteeType(mvo.getCstTypCd2());
			}*/
					
		List<ArcReceiptMainVO> list = (List<ArcReceiptMainVO>) this.arcReceiptMainService.selectListForMgr(rqc);
		if (list!=null&&list.size()>0) {
			//交接单明细查询
			ArcReceiptDetailQueryCondition rdqc=new ArcReceiptDetailQueryCondition();
			rdqc.setArcReceiptMainId(list.get(0).getId());
			List<ArcReceiptDetailVO> arcReceiptDetailVOList = ArcReceiptDetailVOTransform.toVOList(this.arcReceiptMainService.arcReceiptDetailList(rdqc));
			for(int i=0;i<arcReceiptDetailVOList.size();i++) {//遍历交接单明细
				ArcReceiptDetailVO arcReceiptDetailVO = arcReceiptDetailVOList.get(i);
				ArcBscInfoVO arcBscInfoVO = arcBscInfoService.selectById(arcReceiptDetailVO.getArcBscInfo());
				String fileFlagNm="";
				if(arcBscInfoVO != null) {
					arcReceiptDetailVO.setWarrantName(arcBscInfoVO.getWarrantName());
					SysDictionaryDTO dictionary  = sysDictionaryApiService.getCode(ArchiveConstants.SYS_CODE, ArchiveConstants.ORG_CODE,
							ArchiveConstants.ARC001, arcBscInfoVO.getWarrantType());
					if(dictionary != null){
						fileFlagNm=dictionary.getCodeNm();
					}
				}
				//只匹配结清资料
				if (ArchiveConstants.FILE_FLAG_5.equals(arcBscInfoVO.getWarrantType())) {
					//交接单初始化一份
					{
						ArcTransferDetailVO dVo=new ArcTransferDetailVO();
						//dVo.setArcApplyMainId(mgrd.getArcApplyMainId());//归档申请主表ID
						dVo.setArcReceiptDetailId(arcReceiptDetailVO.getId());//交接单明细ID
						dVo.setContractNo(contractNo);//融资租赁合同编号
						dVo.setPaylistCode(paySchNo);//支付表号
						dVo.setFileFlag(arcBscInfoVO.getWarrantType());//权证类别(合同、权证资料等)[档案基础信息]
						dVo.setFileName(arcBscInfoVO.getWarrantName());//权证名称[档案基础信息]
						dVo.setArcLevel(arcBscInfoVO.getArcLevel());//归类级别(合同归类、支付表归类)[档案基础信息]
						dVo.setDossierTemp(arcReceiptDetailVO.getType());//1原件/2复印件/3电子[交接单明细] 
						dVo.setIschoice(arcReceiptDetailVO.getIschoice());//是否必选[交接单明细] 0必选 1 非必选
						dVo.setDossierCount(arcReceiptDetailVO.getFenshu());//要求份数[交接单明细]
						dVo.setTransferNumber(0L);//已移交份数
						//dVo.setDossierCountI(0L);//归档中份数
						//dVo.setDossierCountT(0L);//已归档份数
						
						//dVo.setEleId(mgrd.getEleId());//电子合同ID(从项目电子合同记录表查出)
						//dVo.setThisCount(mgrd.getDossierCount());//本次归档份数
						//dVo.setCheckCount(mgrd.getCheckCount());//权证审核份数
						dVo.setIsValid(1);//是否有效（1：是，0：否）（SYS0021）
						dVo.setIsDel(0);//是否删除（1：是，0：否）
						
						dVo.setFileFlagNm(arcBscInfoVO.getWarrantTypeNm());//权证类别(合同、权证资料等)[档案基础信息]
						dVo.setArcLevelNm(arcBscInfoVO.getArcLevelNm());//归类级别(合同归类、支付表归类)[档案基础信息]
						dVo.setDossierTempNm(arcReceiptDetailVO.getType());//1原件/2复印件/3电子[交接单明细] 
						dVo.setIschoiceNm(arcReceiptDetailVO.getIschoice());//是否必选[交接单明细] 0必选 1 非必选
						dVo.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
						dVo.setCrtTm(new Date());
						/*//区分合同，支付表
						if (arcBscInfoVO.getArcLevel().equals(ArchiveConstants.ARCLEVEL_2)) {
							dlist.add(dVo);
						}else {
							clist.add(dVo);
						}*/
						detailList.add(dVo);
					}//交接单初始化一份
				  }//只匹配结清资料
				}//遍历交接单明细
				
				//Long	arcReceiptMainId=list.get(0).getId();
				mv.setArcReceiptMainId(list.get(0).getId());
				mv.setArcReceiptName(list.get(0).getListName());
				mv.setVersioni(list.get(0).getVersion());
				mv.setArcTransferDetailList(detailList);
			}else {
				BaseLogUtils.error(logger, "initSettleReceipt没找到交接单", "操作数据失败.DATA:" + JSONObject.toJSONString(paySchNo), CurrentThreadContext.getCurrentUserName());
			}
		}catch(Exception ex){
			ex.printStackTrace();
			/*result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());*/
			BaseLogUtils.error(logger, "initSettleReceipt没找到交接单", "操作数据失败.DATA:" + JSONObject.toJSONString(paySchNo) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return 	mv	;			
		
	}
	private DataResultVO transferApplyStartFlow(Long id,Map<String, Object> param,String cstNm) {
		
//		String procDefKey="FLOW_0000_ARC03_001";
//		String procDefId="FLOW_0000_ARC03_001:1:7603537b-21a5-11e8-a7e1-005056b1519e";
//		String procNo="权证移交申请流程";
		
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "transferApplyStartFlow", SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY, CurrentThreadContext.getCurrentUserName());
			return result;
		}
		
		FlowStartParamsDTO flowStartParamsDTO = new FlowStartParamsDTO();
		try {
			//流程定义Key和流程定义ID 如果是前端选择的则直接指定,如果不是则系统自动按照配置选择唯一一条记录,如果找不到会提示
			flowStartParamsDTO.setBusinessKey(String.valueOf(id));
			flowStartParamsDTO.setStartParams(param);//传入参数
//			flowStartParamsDTO.setProcDefKey(procDefKey);cstId
//			flowStartParamsDTO.setProcDefId(procDefId);cstNm
//			flowStartParamsDTO.setProcNo(procNo);
			flowStartParamsDTO.setAudStsCd(FlowConstant.FLOW_CHECK_STATE_IN);
			flowStartParamsDTO.setWordsInTheTable(ArchiveConstants.ARC_FLOW_S_H_ARC);
			flowStartParamsDTO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
			flowStartParamsDTO.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
			flowStartParamsDTO.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
			flowStartParamsDTO.setSysCd(CurrentThreadContext.getCurrentSysCd());
			flowStartParamsDTO.setInitiator(String.valueOf(CurrentThreadContext.getCurrentUserId()));
			flowStartParamsDTO.setInitiatorNm(CurrentThreadContext.getCurrentUserName());
			flowStartParamsDTO.setProcPriority(FlowConstant.FLOW_PRIORITY_EMERGENCY);//优先级,可以在界面定义
			//设置关键字 开始 拼接合同
			StringBuffer keyWords = new StringBuffer();
			try{
//				if(param.containsKey("cnoStr")){
//					keyWords.append(param.get("cnoStr").toString()).append(FlowConstant.FLOW_TASK_BACK_USR_DISPLAY_SEPERATOR);//支付表号	
//				}
				if(param.containsKey("mgrOrgCdStr")){
					String mgrOrgCdStr=param.get("mgrOrgCdStr").toString();
					String[] mgrStr =mgrOrgCdStr.split(",");
					if(mgrStr.length>0){
						for(int k=0;k<mgrStr.length-1;k++){
							String temp=mgrStr[k]+"";
							if(temp.length() > 12){
								temp=temp.substring(0,12);
								if(StringUtils.isNotBlank(temp)){
									List<SysOrgDTO> sysOrgDTOList = this.sysOrgApiService.searchSysOrgListBy(CurrentThreadContext.getCurrentSysCd()); //查询所有组织架构列表
									SysOrgDTO sysOrgDTO = this.sysOrgApiService.selectSysOrgByOrgCd(temp, CurrentThreadContext.getCurrentSysCd());
									if(sysOrgDTO != null) {
										if(StringUtils.isNotEmpty(sysOrgDTO.getOrgDispNm())) {
											String tempStr=sysOrgDTO.getOrgDispNm();
											if(keyWords.indexOf(tempStr)==-1){
												keyWords.append(sysOrgDTO.getOrgDispNm());//组织架构（架构显示名称,例如:重卡-江苏-南京分公司）
											}
										}
										
									}
								}
							}
						}
					}
				}
				if(param.containsKey("payStr")){
					keyWords.append(param.get("payStr").toString()).append(FlowConstant.FLOW_TASK_BACK_USR_DISPLAY_SEPERATOR);//合同号
				}
			}catch(Exception e){
				e.printStackTrace();
				BaseLogUtils.error(logger, "transferApplyStartFlow", "keyWords：" +keyWords.toString(), CurrentThreadContext.getCurrentUserName());
			}
			BaseLogUtils.info(logger, "transferApplyStartFlow", "keyWords：" +keyWords.toString(), CurrentThreadContext.getCurrentUserName());
			//设置关键字 结束 
			flowStartParamsDTO.setSearchDesc(keyWords.toString());
			flowStartParamsDTO.setCstNm(cstNm);
			
			/*  //判断是什么流程-分别定义相应模块类型
	        if(null != qc.getFlowModelType()){
	        	flowStartParamsDTO.setModelTyp(qc.getFlowModelType());//需要和流程配置中的模块类型匹配
	        	if(qc.getFlowModelType().equals(FncPrjContMainConstant.FLOW_MODEL_TYP_CONT_APPROVAL)) {//合同审核
	                flowStartParamsDTO.setWordsInTheTable(FncPrjContMainConstant.SYS_FLOW_S_CONT_H);
	    		}else if(qc.getFlowModelType().equals(FncPrjContMainConstant.FLOW_MODEL_TYP_CONT_STAMP)){//盖章申请
	    	        flowStartParamsDTO.setWordsInTheTable(FncPrjContMainConstant.SYS_FLOW_S_RFSEAL_H);
	    		}else{
	                flowStartParamsDTO.setWordsInTheTable(FncPrjContMainConstant.SYS_FLOW_S_CONT_H);
	    		}
	        }else{
	        	flowStartParamsDTO.setModelTyp(FncPrjContMainConstant.FLOW_MODEL_TYP_CONT_APPROVAL);//需要和流程配置中的模块类型匹配
	            flowStartParamsDTO.setWordsInTheTable(FncPrjContMainConstant.SYS_FLOW_S_CONT_H);
	        }*/
	        
			flowStartParamsDTO.setModelTyp(ArchiveConstants.FLOW_MODEL_TYP_ARC_TRANSFER);//需要和流程配置中的模块类型匹配
			
			
//			flowStartParamsDTO.setModelTyp(FncPrjContMainConstant.FLOW_MODEL_TYP_CONT_APPROVAL);//需要和流程配置中的模块类型匹配
//            flowStartParamsDTO.setWordsInTheTable(FncPrjContMainConstant.SYS_FLOW_S_CONT_H);
            
			DataResultDTO dataResultDTO = this.arcTransferMainService.addFlowStart(flowStartParamsDTO);
			if(!dataResultDTO.getCode().equals(BaseExceptionConstant.BASE_EXCEPTION_CODE_200)){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_OPERATE_FAIL);
			}
			if(null!=dataResultDTO && null!=dataResultDTO.getData()){
				FlowStartedDTO flowStartedDTO = (FlowStartedDTO) dataResultDTO.getData();
				if(StringUtils.isNotBlank(flowStartedDTO.getNextOperUsrNames())){
	                result.setInfo("下一个节点操作人:"+flowStartedDTO.getNextOperUsrNames());
	            }else{
	                result.setInfo("流程发起成功");
	            }
			}
			
		} catch (BaseException e) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(e.getMessage());
			BaseLogUtils.info(logger, "transferApplyStartFlow", "错误[BaseException],请求参数：" + JSONObject.toJSONString(flowStartParamsDTO) + " -ERROR:" +e.getMessage(), CurrentThreadContext.getCurrentUserName());
			e.getStackTrace();
		} catch (Exception e) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "transferApplyStartFlow", "错误[Exception],请求参数：" + JSONObject.toJSONString(flowStartParamsDTO) + " -ERROR:" +e.getMessage(), CurrentThreadContext.getCurrentUserName());
			e.getStackTrace();
		}
		return result;
	}
	/**
	 * 明细
	 */
	@RequestMapping(value = "/getView.do", method = { RequestMethod.GET})
	public String getView(HttpServletRequest request, HttpServletResponse response) {
		try {
			
			String id = "0";
			request.setAttribute("id",id);
			String paySchNo=request.getParameter("paySchNo");
			//查找申请单
			//ArcTransferMainVO avo= this.arcTransferMainService.selectById(Long.valueOf(id));
			ArcTransferMainQueryCondition condition=new ArcTransferMainQueryCondition();
			condition.setPaySchNo(paySchNo);
			Pager page=new Pager();
			page.setEveryPage(10000);
			page.setCurrentPage(0);
			page.setCondition(condition);
			page=this.arcTransferMainService.searchListPage(page);
			List<ArcTransferMainDTO> list = (List<ArcTransferMainDTO>) page.getResultList();
			ArcTransferMainVO avo=new ArcTransferMainVO();
			if (list!=null) {
				id=list.get(0).getId().toString();
				avo=ArcTransferMainVOTransform.toVO(list.get(0));
			}
			//申请单明细
			//如果不是移交中则只显示归档
			
			ArcTransferDetailQueryCondition dQc=new ArcTransferDetailQueryCondition();
			dQc.setArcTransferMainId(Long.valueOf(id));
			List<ArcTransferDetailVO> dList=this.arcTransferDetailService.searchList(dQc);
			
			request.setAttribute("dList",dList);
			//档案明细，归档表
			
			ArcMgrMainQC qc=new ArcMgrMainQC();
			qc.setPaySchNo(paySchNo);
			List<ArcMgrMainVO> mgrList=this.arcMgrMainService.selectList(qc);
			for (int i = 0; i < mgrList.size(); i++) {
				ArcMgrMainVO vo=mgrList.get(i);
				ArcMgrDetailQC mdqc=new ArcMgrDetailQC();
				mdqc.setArcMgrMainId(vo.getId());
				List<ArcMgrDetailVO> ppList=this.arcMgrDetailService.searchList(mdqc);//支付表明细
				if (ppList!=null) {
						// 合同电子赋值
						this.arcMgrMainService.getFilSign(ppList);
						//去除结清资料
						for (int j = 0; j < ppList.size(); j++) {
							ArcMgrDetailVO dvo=ppList.get(j);
							if (ArchiveConstants.FILE_FLAG_5.equals(dvo.getFileFlag())) {
									ppList.remove(dvo);
									--j;
							}
						}
				}
				vo.setArcMgrDetailList(ppList);
			}
			request.setAttribute("paySchNo",paySchNo);
			request.setAttribute("mgr",avo);
			request.setAttribute("mgrList",mgrList);
			
			
			
			
			//邮寄信息
			List<ArcPostInfoVO> plist=new ArrayList<ArcPostInfoVO>();		
			ArcPostInfoQC condition2=new ArcPostInfoQC();
			condition2.setArcAppId(Long.valueOf(id));
			plist=this.arcPostInfoService.searchList(condition2);
			//判断一下是否是新流程，多条移交支付表发起的流程
			ArcTransferMainQueryCondition mqc=new ArcTransferMainQueryCondition();
			mqc.setPaySchNo(paySchNo);
			List<ArcTransferMainVO> mlist = this.arcTransferMainService.searchListByCondition(mqc,CurrentThreadContext.getCurrentSysCd(),CurrentThreadContext.getCurrentOrgCd());
			if(mlist.size()>0 && mlist!=null){
				List<ArcPostInfoVO> plist3=new ArrayList<ArcPostInfoVO>();	
				ArcTransferMainVO mvo=mlist.get(0);
				if(StringUtils.isNotEmpty(mlist.get(0).getParentId()) && mlist.get(0).getParentId()!=null){
					Long parentId	=mlist.get(0).getParentId();
					ArcPostInfoQC condition3=new ArcPostInfoQC();
					condition3.setArcAppId(Long.valueOf(parentId));
					plist3=this.arcPostInfoService.searchList(condition3);
					if(plist3!=null && plist3.size()>0){
						plist.addAll(plist3);
					}
				}
			}
			//end 判断结束
			request.setAttribute("plist",plist);
			BaseLogUtils.info(logger, "getFlow", "跳转到列表页面.", CurrentThreadContext.getCurrentUserName());

		} catch (Exception e) {
			// TODO: handle exception
			BaseLogUtils.error(logger, "getFlow", e.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return "archive/arcTransferMain/arcTransferView";
		
	}
	/**
	 * 初始化权证资料列表
	 */
	@RequestMapping(value = "/initGridList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initGridList(HttpServletRequest request, HttpServletResponse response) {
		String contractNo = request.getParameter("contractNo");
		String payListCode = request.getParameter("payListCode");
		String arcLevel = request.getParameter("arcLevel");
		String fileFlag = request.getParameter("fileFlag");
		String ssign = request.getParameter("ssign");
		String sysCd = CurrentThreadContext.getCurrentSysCd(); 
		String orgCd = CurrentThreadContext.getCurrentOrgCd();
		ArcMgrDetailQC qc = new ArcMgrDetailQC();
		qc.setContractNo(contractNo);
		if("2".equals(arcLevel)){
			qc.setPaylistCode(payListCode);
		}
		qc.setIsDel(ArchiveConstants.IS_DEL);//未删除
		qc.setArcLevel(arcLevel);//归档级别：1 合同类  2 支付表类
		if (StringUtils.isNotEmpty(fileFlag)) {//权证类别
			qc.setFileFlag(fileFlag);
		}
		List<ArcMgrDetailVO> mgrList = this.arcMgrDetailService.searchList(qc);
		List<ArcMgrDetailVO> remgrList=mgrList;//结果集合
		//过滤 add by gengchunlan 20190507
		if(StringUtils.isNotBlank(ssign)){//sign002 省公司 sign=001总公司 归档地点 1总部 2省公司
			if("001".equals(ssign)){//保留归档地点为总公司
				for(int i=0;i<mgrList.size();i++){
					ArcMgrDetailVO dv= mgrList.get(i);
					if(dv.getArcReceiptDetailVO()!=null && dv.getArcReceiptDetailVO().getArcPlace()!=null ){
						ArcReceiptDetailVO re=dv.getArcReceiptDetailVO();
						if("2".equals(re.getArcPlace())){//过滤掉省公司的权证资料
							remgrList.remove(dv);
							--i;
						}
					}
				}
			}else if("002".equals(ssign)){//保留归档地点为省公司
				for(int i=0;i<mgrList.size();i++){
					ArcMgrDetailVO dv= mgrList.get(i);
					if(dv.getArcReceiptDetailVO()!=null && dv.getArcReceiptDetailVO().getArcPlace()!=null ){
						if("1".equals(dv.getArcReceiptDetailVO().getArcPlace())){//过滤掉总公司的权证资料
							remgrList.remove(dv);
							--i;
						}
					}
				}
			}
		}//end 过滤结束
		ListPageVO<ArcMgrDetailVO> listPage = new ListPageVO<ArcMgrDetailVO>(remgrList, remgrList.size());
		BaseLogUtils.info(logger, "initGridList", "查询数据完成. DATA:" + JSONObject.toJSONString(listPage), CurrentThreadContext.getCurrentUserName());
		return listPage;
	}
	/**
	 * 初始化结清资料列表
	 */
	@RequestMapping(value = "/initJGridList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initJGridList(HttpServletRequest request, HttpServletResponse response) {
		
		String transferMainId = request.getParameter("transferMainId");
		String ssign = request.getParameter("ssign");
		String sysCd = CurrentThreadContext.getCurrentSysCd(); 
		String orgCd = CurrentThreadContext.getCurrentOrgCd();
		
		ArcTransferDetailQueryCondition dQc=new ArcTransferDetailQueryCondition();
		dQc.setArcTransferMainId(Long.valueOf(transferMainId));
		List<ArcTransferDetailVO> dList=this.arcTransferDetailService.searchList(dQc);
		request.setAttribute("dList",dList);
		request.setAttribute("sign",ssign);
		//获取上传的扫描件文件列表
		for(int i=0;i<dList.size();i++){
			ArcTransferDetailVO  deVo=dList.get(i);
			if(deVo.getEleId()!=null){
				SysUlFilesRecQueryCondition condition = new SysUlFilesRecQueryCondition();//文件
				//设置公共属性
				condition.setPkId(deVo.getEleId().toString());
				//系统代码
			    condition.setSysCd(sysCd);
			    List<SysUlFilesRecVO> filesList = this.sysUlFilesRecService.searchList(condition);//扫描件集合
				if(CollectionUtils.isNotEmpty(filesList) && filesList.size()>0){
					deVo.setScanAttcheList(filesList);
					
				}
			}
			//设置一下transferNumber等于0时候带入要求 dossierCount sign
			if(ssign!=null && "003".equals(ssign)){
				if(deVo.getTransferNumber()>0){
				}else{
					deVo.setTransferNumber(deVo.getDossierCount());
				}
			}//设置完毕
		}
		ListPageVO<ArcTransferDetailVO> listPage = new ListPageVO<ArcTransferDetailVO>(dList, dList.size());
		BaseLogUtils.info(logger, "initGridList", "查询数据完成. DATA:" + JSONObject.toJSONString(listPage), CurrentThreadContext.getCurrentUserName());
		return listPage;
	}
	/**
	 * 获取系统用户(工号、姓名)
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getSysUsr.do")
	@ResponseBody
	public Object getSysUsr(HttpServletRequest request) throws BaseException {
		
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_NO, SysLogConstant.LOG_CMM_OPERATE_FAIL);
		try {
			String jobNum = request.getParameter("jobNum");//工号
			if(StringUtils.isNotBlank(jobNum)){
				SysUsrDTO sysUsrDTO = this.sysUsrApiService.selectSysUsrWithAuthBy(CurrentThreadContext.getCurrentSysCd(), jobNum);
				if(sysUsrDTO==null){
					//判断是否根据工号查询出人员了，如果是，则不继续，否则继续根据姓名查一下
					SysUsrQueryCondition ssyqc=new SysUsrQueryCondition();
					ssyqc.setRlNm(jobNum);
					ssyqc.setSysCd(CurrentThreadContext.getCurrentSysCd()); 
					List<SysUsrDTO> userList=sysUsrApiService.searchSysUsrList(ssyqc);
					if(userList!=null && userList.size()>0){
						sysUsrDTO=userList.get(0);
					}
				}
				result.setData(sysUsrDTO);
				
				result.setSuccess(BaseConstant.IS_YESNO_YES);
				result.setInfo("");
				BaseLogUtils.info(logger, "getSysUsr", "获取数据成功."+sysUsrDTO, CurrentThreadContext.getCurrentUserName());
			}
			
		}catch(Exception ex) {
			result.setInfo(ex.getMessage());
			BaseLogUtils.error(logger, "getSysUsr", "获取-失败."+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	/**
	 * 校验客户是否有小贷未结清
	 */
	@RequestMapping(value = "/checkSmallLoan.do")
	@ResponseBody
	public Object checkSmallLoan(HttpServletRequest request, HttpServletResponse response) {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_NO, SysLogConstant.LOG_CMM_OPERATE_FAIL);
		try {
			String paySchId = request.getParameter("paySchId");//支付表id
			String cstId = request.getParameter("cstId");//承租人id
			
			if(StringUtils.isNotBlank(paySchId) && StringUtils.isNotBlank(cstId) ){
				DataResultDTO	re = this.mcrCstCrLimApiService.jycheck(Long.parseLong(cstId), Long.parseLong(paySchId));
				BaseLogUtils.info(logger, "checkSmallLoan", "获取数据成功."+JSONObject.toJSONString(re), CurrentThreadContext.getCurrentUserName());
				result.setData(re.getCode());
				result.setSuccess(BaseConstant.IS_YESNO_YES);
				result.setInfo(re.getInfo());
			}
			
		}catch(Exception ex) {
			result.setInfo(ex.getMessage());
			BaseLogUtils.error(logger, "checkSmallLoan", "获取-失败."+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	/**
	 * 校验发起移交流程 /1 核查该支付表下有未归还权证资料，请先结束流程  2 //校验客户是否有小贷
	 */
	@RequestMapping(value = "/checkStartProcess.do")
	@ResponseBody
	public Object checkStartProcess(HttpServletRequest request, HttpServletResponse response) {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_NO, SysLogConstant.LOG_CMM_OPERATE_FAIL);
		int res=0;//re=1 1 核查该支付表下有未归还权证资料，请先结束流程  2 客户是否有小贷
		String payIdList = request.getParameter("payIdList");//支付表id
		BaseLogUtils.info(logger, "checkStartProcess", "移交校验===payIdList："+JSONObject.toJSONString(payIdList), CurrentThreadContext.getCurrentUserName());
		try {
			ArcTransferMainQueryCondition qc=new ArcTransferMainQueryCondition();
			Pager page = new Pager();
			page.setEveryPage(50); //设置成50，否则默认10条，有问题（modify by JL at 20190809）
			if(StringUtils.isNotEmpty(payIdList)){
				qc.setPayIdList(payIdList);
				page.setCondition(qc);
				Pager pager = this.arcTransferMainService.selectListForListPage(page);
				List<ArcTransferMainVO> list =ArcTransferMainVOTransform.toVOList((List<ArcTransferMainDTO>) pager.getResultList());
				if(CollectionUtils.isNotEmpty(list) && list.size()>0){ //加非空判断和日志（modify by JL at 20190809）
					BaseLogUtils.info(logger, "checkStartProcess", "移交校验===transferList："+JSONObject.toJSONString(list), CurrentThreadContext.getCurrentUserName());
					//根据支付表号查询是否有未归还的权证资料
					for(ArcTransferMainVO vo:list){
						//校验核查该支付表下有未归还权证资料，请先结束流程
						ArcMgrDetailQC dqc = new ArcMgrDetailQC();
						dqc.setContractNo(vo.getContractNo());
						dqc.setPaylistCode(vo.getPaySchNo());
						dqc.setIsDel(ArchiveConstants.IS_DEL);//未删除
						dqc.setArcLevel("2");//归档级别：1 合同类  2 支付表类
						dqc.setFileFlag("3");//权证类别
						List<ArcMgrDetailVO> mgrList = this.arcMgrDetailService.searchList(dqc);
						BaseLogUtils.info(logger, "checkStartProcess", "移交校验===mgrList："+JSONObject.toJSONString(mgrList), CurrentThreadContext.getCurrentUserName());
						if(CollectionUtils.isNotEmpty(mgrList) && mgrList.size()>0){ //加非空判断（modify by JL at 20190809）
							for(ArcMgrDetailVO de:mgrList){
								if(de.getBorrowStatus()!=null && !"".equals(de.getBorrowStatus()) && "1".equals(de.getBorrowStatus())){
									res=1;
									result.setData(res);
									result.setInfo(vo.getPaySchNo()+"支付表下有未归还权证资料，请先结束流程");
									return result;
								}
							}//end 校验核查该支付表下有未归还权证资料，请先结束流程
						}
						//校验客户是否有小贷未结清
						DataResultDTO re = this.mcrCstCrLimApiService.jycheck(Long.parseLong(vo.getCstId()), vo.getPaySchId());
						BaseLogUtils.info(logger, "checkStartProcess", "小贷校验.CstId="+vo.getCstId()+"; PaySchId="+vo.getPaySchId()+"; re="+JSONObject.toJSONString(re), CurrentThreadContext.getCurrentUserName());
						if(re!=null && re.getCode()!=null && !"1".equals(re.getCode())){
							res=2;
							result.setData(res);
							result.setInfo(vo.getCstNm()+re.getInfo());
							return result;
						}
					}
				}else{
					BaseLogUtils.info(logger, "checkStartProcess", "移交校验.获取档案归档列表为空！"+JSONObject.toJSONString(list), CurrentThreadContext.getCurrentUserName());
				}
			}
			result.setData("0");
		}catch(Exception ex) {
			result.setData("2");
			result.setInfo(ex.getMessage());
			BaseLogUtils.error(logger, "checkStartProcess", "获取-失败."+ex.getMessage()+payIdList, CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	/**
	 * 校验结清资料扫描件是否上传
	 */
	@RequestMapping(value = "/checkScanFile.do")
	@ResponseBody
	public Object checkScanFile(HttpServletRequest request, HttpServletResponse response) {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_NO, SysLogConstant.LOG_CMM_OPERATE_FAIL);
		int res=0;
		try {
			String mainId = request.getParameter("mainId");//支付表id
			if(StringUtils.isNotBlank(mainId)){
				ArcTransferMainQueryCondition qqc = new ArcTransferMainQueryCondition();
	            qqc.setParentId(Long.parseLong(mainId));
	        	List<ArcTransferMainVO> trMain = this.arcTransferMainService.searchListByCondition(qqc, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
	        	List<SysUlFilesRecDTO> scanAttcheList =new ArrayList<SysUlFilesRecDTO>();
	         	if(null!=trMain && trMain.size()>0){
	         	   for(ArcTransferMainVO mv:trMain){
	         		   ArcTransferDetailQueryCondition dc=new ArcTransferDetailQueryCondition();
	         		   if(StringUtils.isNotBlank(mv.getId().toString())){
	         			   dc.setArcTransferMainId(mv.getId());
	         			   List<ArcTransferDetailVO> dList=this.arcTransferDetailService.searchList(dc);
	 	   	        		for(int i=0;i<dList.size();i++){
	 	   	        			ArcTransferDetailVO  deVo=dList.get(i);
	 	   	        			if(deVo.getEleId()!=null){
	 	   	        				SysUlFilesRecQueryCondition sfqc = new SysUlFilesRecQueryCondition();//文件
	 	   	        				//设置公共属性
	 	   	        				sfqc.setPkId(deVo.getEleId().toString());
	 	   	        				//系统代码
	 	   	        				sfqc.setSysCd(CurrentThreadContext.getFlServiceSysCd());
	 	   	        			    List<SysUlFilesRecDTO> filesList = this.uploadApiService.searchSysUlFilesRecList(sfqc);//扫描件集合
	 	   	        				if(filesList.size()==0 || null==filesList){
		 	   	        				res=2;
			 	   						result.setData(res);
			 	   						result.setInfo(mv.getPaySchNo()+"请核查一下是否上传了扫描件!");
			 	   						return result;
	 	   	        				}
	 	   	        			}else if(null==deVo.getEleId()){
		 	   	        			res=2;
		 	   						result.setData(res);
		 	   						result.setInfo(mv.getPaySchNo()+"请核查一下是否上传了扫描件!");
		 	   						return result;
	 	   	        			}
	 	   	        		}  
	         		   } 
	         	   }	
	         	   
	         	}//结清扫描件end
	         result.setData("0");
			}
		}catch(Exception ex) {
			result.setInfo(ex.getMessage());
			BaseLogUtils.error(logger, "checkScanFile", "获取-失败."+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	/**
	 * 新移交申请流程页面
	 */
	@RequestMapping(value = "/toApplyTransferFlowPage.do", method = { RequestMethod.GET})
	public String toApplyTransferFlowPage(HttpServletRequest request, HttpServletResponse response) {
		try{	
			String payIdList = request.getParameter("payIdList");//选择的多条移交数据
			BaseLogUtils.info(logger, "toApplyTransferFlowPage", "payIdList:"+payIdList);
			request.setAttribute("sendTypeList", this.sysDictionaryApiService.getKvList(ArchiveConstants.ARC010,CurrentThreadContext.getCurrentSysCd(),CurrentThreadContext.getCurrentOrgCd()));//接收方式
			request.setAttribute("sendCompanyList", arcBscInfoService.getKvList(CurrentThreadContext.getCurrentSysCd(),CurrentThreadContext.getCurrentOrgCd(), ArchiveConstants.ARC012));//邮寄公司
			request.setAttribute("payIdList",payIdList);
			request.setAttribute("sysDate", DateUtils.formatDateToString(new Date(), DateUtils.YYYY_MM_DD));
			request.setAttribute("loginUsrNm", CurrentThreadContext.getCurrentUserName());
			request.setAttribute("prefixUrl",PropertiesCacheUtils.getProperty(SysUlFilesRecConstant.SYS_FILE_UPLOAD_SERVER_PATH));
		} catch (Exception e) {
			BaseLogUtils.error(logger, "toApplyTransferFlowPage", e.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return "archive/arcTransferMain/applyTransferFlow";
		
	}
	/**
	 * 移交申请选择数据结果集 列表
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping("/initTransferList.do")
	@ResponseBody
	public Object initTransferList(HttpServletRequest request, HttpServletResponse response) {
		this.setAttribute(request);
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		String payIdList = request.getParameter("payIdList");//选择的多条移交数据     
		String parentId = request.getParameter("parentId");
		String sign = request.getParameter("sign");
		Pager page = new Pager();
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}
		if (StringUtils.isNotEmpty(pageSize)) {
			page.setEveryPage(Integer.parseInt(pageSize));
		}
		ListPageVO<ArcTransferMainVO> listPage=new ListPageVO<ArcTransferMainVO>();
		//查询条件
		ArcTransferMainQueryCondition qc=new ArcTransferMainQueryCondition();
		if(StringUtils.isNotEmpty(payIdList)){
			qc.setPayIdList(payIdList);
			//权限添加
			qc.setUsrId(CurrentThreadContext.getCurrentUserId());
			page.setCondition(qc);
			Pager pager = this.arcTransferMainService.selectListForListPage(page);
			List<ArcTransferMainVO> list =ArcTransferMainVOTransform.toVOList((List<ArcTransferMainDTO>) pager.getResultList());
			//获取上传的其他文件列表
			for(int i=0;i<list.size();i++){
				ArcTransferMainVO  deVo=list.get(i);
				if(deVo.getId()!=null){//档案管理主表id
					SysUlFilesRecQueryCondition condition = new SysUlFilesRecQueryCondition();//文件
					//设置公共属性
					condition.setPkId(deVo.getId().toString());
					condition.setCfgDtlCd(ArchiveConstants.OTH_CFG_DTL_CD);
					//系统代码
				    condition.setSysCd(CurrentThreadContext.getCurrentSysCd());
				    List<SysUlFilesRecVO> filesList = this.sysUlFilesRecService.searchList(condition);//扫描件集合
					if(CollectionUtils.isNotEmpty(filesList) && filesList.size()>0){
						deVo.setUploadFileList(filesList);
					}
				}
			}//end list
			listPage = new ListPageVO<ArcTransferMainVO>(list, pager.getTotalCount());
		}
		if(StringUtils.isNotEmpty(parentId)){
			qc.setParentId(Long.parseLong(parentId));
			List<ArcTransferMainVO> list = this.arcTransferMainService.searchListByCondition(qc,CurrentThreadContext.getCurrentSysCd(),CurrentThreadContext.getCurrentOrgCd());
			if(sign!=null && "006".equals(sign)){//移交申请流程  发起权证移交节点(sign=006)
				//获取上传的其他文件列表
				for(int i=0;i<list.size();i++){
					ArcTransferMainVO  deVo=list.get(i);
					//根据支付表号获取档案管理主表
					ArcMgrMainQC mqc=new ArcMgrMainQC();
					if(StringUtils.isNotEmpty(deVo.getPaySchId())){
						mqc.setPaySchId(deVo.getPaySchId());
						List<ArcMgrMainVO> mgrList= arcMgrMainService.selectList(mqc);
						if(mgrList!=null && mgrList.size()>0){//档案管理主表id
							SysUlFilesRecQueryCondition condition = new SysUlFilesRecQueryCondition();//文件
							//设置公共属性
							condition.setPkId(mgrList.get(0).getId().toString());
							condition.setCfgDtlCd(ArchiveConstants.OTH_CFG_DTL_CD);
							//系统代码
						    condition.setSysCd(CurrentThreadContext.getCurrentSysCd());
						    List<SysUlFilesRecVO> filesList = this.sysUlFilesRecService.searchList(condition);//扫描件集合
							if(CollectionUtils.isNotEmpty(filesList) && filesList.size()>0){
								deVo.setUploadFileList(filesList);
							}
							deVo.setArcMgrMainId(mgrList.get(0).getId());
						}
					}
				}//end list
			}
			listPage = new ListPageVO<ArcTransferMainVO>(list, list.size());
		}
		BaseLogUtils.info(logger, "initTransferList", "查询数据完成. DATA:" + JSONObject.toJSONString(page), CurrentThreadContext.getCurrentUserName());
		return listPage;
	}
	/**
	 * 上传移交申请其他资料
	 */
	@RequestMapping(value = "/saveUploadRecord.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object saveUploadRecord(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
		String fileNm = request.getParameter("fileNm");
		String filePath = request.getParameter("filePath");
		String pkId = request.getParameter("pkId");
		String up_file_id = request.getParameter("up_file_id");
		String receipt_file_id = request.getParameter("receipt_file_id");
		String cfgCd = request.getParameter("cfgCd");
		String cfgDtlCd = request.getParameter("cfgDtlCd");
		String tabNm =request.getParameter("tabNm");
		String fileRem=request.getParameter("fileRem");;//备注 存放支付表号
		try {
			SysUlFilesRecVO sysUlFilesRecVO=new SysUlFilesRecVO();
			sysUlFilesRecVO.setTabNm(tabNm);
			sysUlFilesRecVO.setCrtTm(new Date());
			sysUlFilesRecVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
			sysUlFilesRecVO.setMdfTm(new Date());
			sysUlFilesRecVO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
			sysUlFilesRecVO.setIsDel(BaseConstant.IS_YESNO_NO);
			sysUlFilesRecVO.setFileNm(fileNm);
			sysUlFilesRecVO.setFilePath(filePath);
			sysUlFilesRecVO.setPkId(pkId);
			sysUlFilesRecVO.setFileRem(fileRem);
			sysUlFilesRecVO.setSysCd(CurrentThreadContext.getCurrentSysCd());
			sysUlFilesRecVO.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
			sysUlFilesRecVO.setCfgCd(cfgCd);
			sysUlFilesRecVO.setCfgDtlCd(cfgDtlCd);
			sysUlFilesRecVO.setAbsLocPath(PropertiesCacheUtils.getProperty(UploadConstant.UPLOAD_ROOT_PATH)+sysUlFilesRecVO.getFilePath());
			Long id=sysUlFilesRecService.add(sysUlFilesRecVO);
			sysUlFilesRecVO.setId(id);
			result.setData(sysUlFilesRecVO);
			//如果之前已经上传过了，删掉
			if(StringUtils.isNotBlank(up_file_id)){
				List<Long> ar=new ArrayList<Long>();
				ar.add(Long.parseLong(up_file_id));
				sysUlFilesRecService.removeByIds(ar);
			}
			//如果之前已经上传过了，删掉
			if(StringUtils.isNotBlank(receipt_file_id)){
				List<Long> ar=new ArrayList<Long>();
				ar.add(Long.parseLong(receipt_file_id));
				sysUlFilesRecService.removeByIds(ar);
			}
			BaseLogUtils.info(logger, "saveUploadRecord", "上传t.[id="+id+"] DATA:" + JSONObject.toJSONString(filePath), CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.error(logger, "saveUploadRecord", "上传t.DATA:" + JSONObject.toJSONString(filePath) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "saveUploadRecord", "上传t.DATA:" + JSONObject.toJSONString(filePath) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	/**
	 * 发起新移交申请(数据保存和流程发起)
	 */
	@RequestMapping(value = "/transferApplyStartN.do")
	@ResponseBody
	public Object transferApplyStartN(ArcTransferMainVO entity,HttpServletRequest request){
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
		try {
			  //1、获取参数
			  String IS_GRP_BIZ = request.getParameter("IS_GRP_BIZ");//是否团单
			  String buOrgCd = request.getParameter("buOrgCd");//事业部
			  String up_file_id=request.getParameter("up_file_id");//解押材料申请表
			  String up_file_path = request.getParameter("up_file_path");//
			 // String prdStsCd = request.getParameter("prdStsCd");//资产状态
			  String _arcTransferMainList = request.getParameter("_arcTransferMainList");
			  BaseLogUtils.info(logger, "transferApplyStartN", "操作数据. DATA:" + IS_GRP_BIZ+":"+buOrgCd+":"+_arcTransferMainList, CurrentThreadContext.getCurrentUserName());
			  entity.setIsValid(ArchiveConstants.IS_VALID);
			  entity.setIsDel(ArchiveConstants.IS_DEL);
			  entity.setCrtTm(new Date());
			  entity.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
			  entity.setCrtUsrNa(CurrentThreadContext.getCurrentUserName());
			  entity.setCstMgrId(CurrentThreadContext.getCurrentUserId());
			  entity.setCstMgrNm(CurrentThreadContext.getCurrentUserName());
			  entity.setCstMgrOrgCd(CurrentThreadContext.getCurrentOrgCd());
			  entity.setIsGrpBiz(IS_GRP_BIZ);
			  //2、保存移交主表与移交明细表
			  Long id = this.arcTransferMainService.transferApplyStart(entity);
			  //3、保存移交 主表父主表，对应关系
			  List<ArcTransferMainVO> list= (List<ArcTransferMainVO>) JsonUtil.toList(_arcTransferMainList, new ArcTransferMainVO());//合同和支付表明细
			  //拼接合同号
			  StringBuffer cnoStr=new StringBuffer();//合同号
			  StringBuffer payStr=new StringBuffer("/");//支付表号
			  StringBuffer mgrOrgCdStr=new StringBuffer();//客户经理组织架构
			  for(ArcTransferMainVO vo:list){
				  //4、初始化一个结清交接单
				  ArcTransferMainVO initMv =initSettleReceiptById(vo.getArcReceiptMainId().toString(), vo.getContractNo(),vo.getPaySchNo());
				  if(initMv.getArcTransferDetailList()!=null){
					  vo.setArcTransferDetailList(initMv.getArcTransferDetailList());
					  vo.setArcReceiptMainId(initMv.getArcReceiptMainId());
					  vo.setArcReceiptName(initMv.getArcReceiptName());
					  vo.setVersioni(initMv.getVersioni());
					 
				  }else{
						BaseLogUtils.error(logger, "initSettleReceipt没找到交接单", "操作数据失败.DATA:" + JSONObject.toJSONString(_arcTransferMainList), CurrentThreadContext.getCurrentUserName());
						result.setSuccess(BaseConstant.IS_YESNO_NO);
						result.setInfo("没找到交接单");
						return result;
				  }
				 vo.setParentId(id);
				 vo.setIsValid(ArchiveConstants.IS_VALID);
				 vo.setIsDel(ArchiveConstants.IS_DEL);
				 vo.setCrtTm(new Date());
				 vo.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
				 vo.setCrtUsrNa(CurrentThreadContext.getCurrentUserName());
				
				 Long mmainid= arcTransferMainService.transferApplyStart(vo);
				 //校验是否开启移交自动生成合同  1 关闭  2开启
				 String isOpen=isCheckAutoContractFlag();//校验是否开启移交自动生成合同  1 关闭  2开启
				 BaseLogUtils.info(logger, "transferApplyStartN", "操作数据. isOpen:" + JSONObject.toJSONString(isOpen), CurrentThreadContext.getCurrentUserName());
				 if("2".equals(isOpen)) {
					//-----start word模板 是需要解押材料才生成word模板
					 if(null!=entity.getIsNeed() && !"".equals(entity.getIsNeed()) && "1".equals(entity.getIsNeed().toString())){
					 	//获取生成word模板所需要的参数值
						 PrjPrdDtlQueryCondition prjPrdDtlQc = new PrjPrdDtlQueryCondition();
						 prjPrdDtlQc.setPaySchNo(vo.getPaySchNo());
						 List<PrjPrdDtlDTO> selectPrjPrdDtlList=projectApiService.selectPrjPrdDtlList(prjPrdDtlQc);
						 String vin="";//车架号
						 String vehNo="";//车牌号
						 if(null!=selectPrjPrdDtlList && selectPrjPrdDtlList.size()>0){
							 PrjPrdDtlDTO dtlDto=selectPrjPrdDtlList.get(0);
							 vin=dtlDto.getVin();
							 //根据dtlId获取上牌信息
							 PrjPrdLicInfoVO LicVo=prjPrdLicInfoService.selectById(dtlDto.getId());
							 if(LicVo!=null && LicVo.getVehNo()!=null && !"".equals(LicVo.getVehNo())){
								 vehNo= LicVo.getVehNo();
							 }
						 }
						 //5.生成word模板
						 Map mmap=new HashMap();
						 mmap.put("pkId", mmainid);
						 mmap.put("PAY_SCH_NO", vo.getPaySchNo());
						 mmap.put("contractNo", vo.getContractNo());
						 mmap.put("vin", vin);//车架号
						 mmap.put("vehNo", vehNo);//车牌号
						 ownerShipWord(request, null,mmap);//所有权转让及解除抵押证明
						 settleProofWord(request, null,mmap);//结清证明
						 attorneyWord(request, null,mmap); //授权委托书
						 applyWord(request, null,mmap);//机动车抵押登记质押备案申请表
					 }
					//-----------word模板 
				 }//end 校验是否开启移交自动生成合同  1 关闭  2开启
				 cnoStr.append(vo.getPaySchNo());//拼接支付表号
				 if(StringUtils.isNotBlank(vo.getContractNo())){
					String tempStr= vo.getContractNo();
					if(StringUtils.isNotBlank(payStr.toString())){
						String ppStr=payStr.toString();
						if(!ppStr.contains(tempStr)){
							payStr.append(vo.getContractNo());//拼接合同号	
						}
					}
				 }
				 mgrOrgCdStr.append(vo.getCstMgrOrgCd()+",");
			  }
			  //6 保存up_file_id
			  if(StringUtils.isNotBlank(up_file_id)){
				  //新增解押文件数据
				  SysUlFilesRecVO rev=sysUlFilesRecService.selectById(Long.parseLong(up_file_id));
				  rev.setPkId(String.valueOf(id));
				  rev.setFilePath(up_file_path);
				  sysUlFilesRecService.add(rev);
				  //删掉之前的数据库记录
				  List<Long> ids=new ArrayList<Long>();
				  ids.add(Long.parseLong(up_file_id));
				  SysUlFilesRecVO fvo =new SysUlFilesRecVO();
				  fvo.setId(Long.parseLong(up_file_id));
				  sysUlFilesRecService.removeByIds(ids);
			  }
			  result.setData(id);
			  BaseLogUtils.info(logger, "transferApplyStartN", "操作数据. DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
			  //判断一下归档地点  省公司  总公司
			  String isProvice="0";//省公司
			  String isZong="0";//总公司
			  try{
				  for(ArcTransferMainVO vo:list){
					  	ArcMgrDetailQC qc = new ArcMgrDetailQC();
						qc.setContractNo(vo.getContractNo());
						qc.setPaylistCode(vo.getPaySchNo());
						qc.setIsDel(ArchiveConstants.IS_DEL);//未删除
						qc.setArcLevel("2");//归档级别：1 合同类  2 支付表类
						qc.setFileFlag("3");
						List<ArcMgrDetailVO> mgrList = this.arcMgrDetailService.searchList(qc);
						// 归档地点 1总部 2省公司
						for(int i=0;i<mgrList.size();i++){
							ArcMgrDetailVO dv= mgrList.get(i);
							if(dv.getArcReceiptDetailVO()!=null && dv.getArcReceiptDetailVO().getArcPlace()!=null ){
								ArcReceiptDetailVO re=dv.getArcReceiptDetailVO();
								if("2".equals(re.getArcPlace())){//过滤掉省公司的权证资料
									isProvice="1";
								}else if("1".equals(dv.getArcReceiptDetailVO().getArcPlace())){//过滤掉总公司的权证资料
									isZong="1";
								}
								//BUG-6405 begin  20190911
								ArcMgrDetailVO arcdv= new ArcMgrDetailVO(); 
								arcdv.setId(dv.getId());
								arcdv.setTransferCount(dv.getDossierCountT());
								arcMgrDetailService.modify(arcdv);
								BaseLogUtils.info(logger, "更新实际移交份数", "transferCount@@arcdv"+JSONObject.toJSONString(arcdv));
								//BUG-6405 end  20190911
							}
						}
			  	   }
			  }catch(Exception e){
				  
			  }
		     //判断归档地点结束	 
			//合同管理员
			String[] stru =null;
  			ArcLocalContractUserQC cqc=new ArcLocalContractUserQC();
  			cqc.setOrgCode(CurrentThreadContext.getCurrentOrgCd());
  			List<ArcLocalContractUserDTO>  clist=arcLocalContractUserService.searchList(cqc, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
  			if(CollectionUtils.isNotEmpty(clist)) {
  				ArcLocalContractUserDTO userDTO = clist.get(0);
  				String userIds = userDTO.getUserIds();
  				if(StringUtils.isNotEmpty(userIds)){
  					BaseLogUtils.info(logger, "executeBefore", "userIds："+userIds);
  					stru=userIds.split(";");
  				}
  			}//end 合同管理员
			  
			  Map<String, Object> param=new HashMap<String, Object>();//放入流程中的参数
			  param.put("isNeed", "1");  
			  if(null!=entity.getIsNeed() && !"".equals(entity.getIsNeed()) && "0".equals(entity.getIsNeed().toString())){
				  param.put("isNeed", "0");  
			  }
			  param.put("cnoStr", cnoStr);
			  param.put("payStr", payStr);
			  param.put("mgrOrgCdStr", mgrOrgCdStr);
			  param.put("isProvice", isProvice);
			  param.put("isZong", isZong);
			  param.put("LH1", 1); 
			  param.put("LH2", 1);
			  param.put("LH3", 1);
			  param.put("prAssignee",stru );
			  //7、流程发起
			  result = transferApplyStartFlow(id,param,"");//cstId cstNm
			  //8、ARC_MGR_MAIN 更新档案管理主表状态为移交中 MgrMainId TRANSFER_STATUS
			  for(ArcTransferMainVO vo:list){
				  ArcMgrMainVO mgr=new ArcMgrMainVO();
				  mgr.setId(vo.getId());
				  mgr.setTransferStatus(ArchiveConstants.ARC_TRANSFER_ING);
				  mgr.setMdfTm(new Date());
				  mgr.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
				  //移交分类字段保存
				 if(vo.getPrdStsCd()!=null && !"".equals(vo.getPrdStsCd()) && 
						 ("S01".equals(vo.getPrdStsCd()) || "S0103".equals(vo.getPrdStsCd()) || "S0104".equals(vo.getPrdStsCd()) || "S0105".equals(vo.getPrdStsCd()))){
					  mgr.setTransferType("1"); //提前借出省公司保管
				  }else{
					  mgr.setTransferType("2"); //正常借出结清
				  }
				  arcMgrMainService.updateById(mgr);  
				  BaseLogUtils.info(logger, "transferApplyStartN", "操作数据. DATA:mgr" + JSONObject.toJSONString(mgr), CurrentThreadContext.getCurrentUserName());
			  }
		}catch (Exception ex) {
			ex.printStackTrace();
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.error(logger, "transferApplyStartN", "操作数据失败.DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	/**
	 * 导出所有权转让及解除抵押证明.doc
	 */
	@RequestMapping(value = "/ownerShipWord.do")
	@ResponseBody
	public void ownerShipWord(HttpServletRequest request, HttpServletResponse response,Map mmap) throws Exception {
		
		String templatePath = request.getSession().getServletContext()
				.getRealPath("/")
				+ "resource/template/warrant/";
		// session.getServletContext().getRealPath("/") +
		// "resource/template/capital/" + filename;
		String fileName = "所有权转让及解除抵押证明.doc";
		String vin="";
	    String PAY_SCH_NO="";
	    String contractNo="";
		if(mmap.containsKey("vin")){// 车架号
			vin=mmap.get("vin").toString();
		}
		if(mmap.containsKey("PAY_SCH_NO")){//支付表号
			PAY_SCH_NO=mmap.get("PAY_SCH_NO").toString();
		}
		if(mmap.containsKey("contractNo")){
			contractNo=mmap.get("contractNo").toString();
		}
		//存放模板数据
		Map<String, Object> dataMap = new HashMap<String, Object>();
		dataMap.put("ton", contractNo);
		dataMap.put("zhi", PAY_SCH_NO);
		dataMap.put("ke", vin);

		Configuration configuration = new Configuration();
		configuration.setDefaultEncoding("utf-8");
		// dataMap 要填入模本的数据文件
		configuration.setDirectoryForTemplateLoading(new File(templatePath));
		Template t = null;
		try {
			// shou.ftl为要装载的模板
			t = configuration.getTemplate("ya.ftl");
		} catch (IOException e) {
			e.printStackTrace();
		}
		// 2 开始导出word模板，通过浏览器导出
		// Writer out = null;
		/*Writer writer = response.getWriter();
		response.reset();// 清除首部的空白行
		fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");
		response.setContentType("application/msword;charset=UTF-8");
		response.setHeader("Content-Disposition", "attachment;filename="
				+ fileName);
		t.process(dataMap, writer);
		// writer.write(writer);
		writer.flush();
		writer.close();*/
		// 输出文档路径及名称
		// 拼接存入路径-------->系统相对路径前缀 + 系统代码 + 模块(自定义) + 时间 + 文件
		JSONObject fileParams=uploadPath(fileName);
		//fileNm
		File pathFile = new File(fileParams.get("pathFile").toString());
		//检查目录
		if (!pathFile.exists()) {
			BaseLogUtils.info(logger, "uploadPath", "文件上传fileParams"+fileParams, CurrentThreadContext.getCurrentUserName());
			// 文件夹不存 创建文件
			boolean createPath = pathFile.mkdirs();
			if (!createPath) {
				BaseLogUtils.info(logger, "uploadPath", "文件上传B33, 创建文件目录失败!" + createPath, CurrentThreadContext.getCurrentUserName());
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "服务器附件目录未创建失败!");
			}
		}
		File outFile = new File(fileParams.get("pathFile").toString()+fileParams.get("uuidfileNm").toString());
		//输出
		Writer out = null;
		FileOutputStream fos = null;
		try {
			fos = new FileOutputStream(outFile);
			OutputStreamWriter oWriter = new OutputStreamWriter(fos, "UTF-8");
			// 这个地方对流的编码不可或缺，使用main（）单独调用时，应该可以，但是如果是web请求导出时导出后word文档就会打不开，并且包XML文件错误。主要是编码格式不正确，无法解析。
			// out = new BufferedWriter(new OutputStreamWriter(new
			// FileOutputStream(outFile)));
			out = new BufferedWriter(oWriter);
		} catch (FileNotFoundException e1) {
			e1.printStackTrace();
		}
		try {
			t.process(dataMap, out);
			out.close();
			fos.close();
		} catch (TemplateException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		//保存文件到数据库
		Map map =new HashMap();
		map.put("fileNm", fileParams.get("fileNm"));
		map.put("filePath", fileParams.get("filePath"));
		map.put("cfgCd", ArchiveConstants.ARC001);
		map.put("cfgDtlCd", ArchiveConstants.QUAN_CFG_DTL_CD);
		map.put("tabNm", ArchiveConstants.TARANSFER_MAIN);
		map.put("pkId", mmap.get("pkId"));//后期记得改
		map.put("PAY_SCH_NO", PAY_SCH_NO);
		saveUpload(map);//保存模板到服务器
	}
	//拼接上传文件路径
	private JSONObject uploadPath(String myFileName){
		JSONObject fileParam = new JSONObject();
		// 拼接存入路径-------->系统相对路径前缀 + 系统代码 + 模块(自定义) + 时间 + 文件
		String rootPath = "";
		String prifixPath = null ;
		if(StringUtils.isNotEmpty(rootPath)){
			prifixPath = PropertiesCacheUtils.getProperty(rootPath);// 根目录
		}else{
			prifixPath = PropertiesCacheUtils.getProperty(UploadConstant.UPLOAD_ROOT_PATH); // 根目录
		}
		StringBuffer savePath = new StringBuffer(prifixPath);// 最终保存路径
		if (!savePath.toString().endsWith(SysUlFilesRecConstant.SYS_FILE_PATH_SLASH)) {// 判断是否以"/"结尾,不是加入斜杠
			savePath.append(SysUlFilesRecConstant.SYS_FILE_PATH_SLASH);
		}
		savePath.append(PropertiesCacheUtils.getProperty(UploadConstant.UPLOAD_COSTOMER_PATH));// 自定义代码-其中包括系统代码
		String modulePath="arcfile/transfer";
		if (StringUtils.isNotEmpty(modulePath)) {// 如果不等于空则加入
			//modulePath = PropertiesCacheUtils.getProperty(modulePath);
			if (modulePath.startsWith(SysUlFilesRecConstant.SYS_FILE_PATH_SLASH)) {// 判断是否以"/"开头
				savePath.append(modulePath.substring(1));
			} else {
				savePath.append(modulePath);
			}
		}
		BaseLogUtils.info(logger, "uploadPath", "文件上传savePath"+savePath, CurrentThreadContext.getCurrentUserName());
		if (!savePath.toString().endsWith(SysUlFilesRecConstant.SYS_FILE_PATH_SLASH)) {// 判断是否以"/"结尾
			savePath.append(SysUlFilesRecConstant.SYS_FILE_PATH_SLASH);
		}
		String currentTime = DateUtils.formatDateToString(new Date(), DateUtils.YYYYMMDD);
		savePath.append(currentTime);
		savePath.append(SysUlFilesRecConstant.SYS_FILE_PATH_SLASH);
		BaseLogUtils.info(logger, "uploadPath", "文件上传B3savePath"+savePath, CurrentThreadContext.getCurrentUserName());
		// 检查目录
		/*File pathFile = new File(savePath.toString());
		BaseLogUtils.info(logger, "uploadPath", "文件上传B31->"+savePath.toString(), CurrentThreadContext.getCurrentUserName());
		if (!pathFile.exists()) {
			BaseLogUtils.info(logger, "uploadPath", "文件上传B32"+savePath, CurrentThreadContext.getCurrentUserName());
			// 文件夹不存 创建文件
			boolean createPath = pathFile.mkdirs();
			if (!createPath) {
				BaseLogUtils.info(logger, "uploadPath", "文件上传B33, 创建文件目录失败!" + createPath, CurrentThreadContext.getCurrentUserName());
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "服务器附件目录未创建失败!");
			}
		}*/
		fileParam.put("pathFile", savePath.toString());
		String _ext = myFileName.substring(myFileName.lastIndexOf("."));
		String randomFileName = UUID.randomUUID().toString().replace("-", "");
		String fileName = randomFileName + _ext;
		// 定义上传路径
		String path = savePath.toString() + fileName;
		fileParam.put("fileNm", myFileName);
		fileParam.put("uuidfileNm", fileName);
		String serverPath = /* serverPrefixPath + */ path.replace(prifixPath, "");
		fileParam.put("filePath", serverPath);
		BaseLogUtils.info(logger, "uploadPath", "文件上传B4"+fileParam, CurrentThreadContext.getCurrentUserName());
		return fileParam;
	}
	/**
	 * 保存文件到数据库  ARC001 40  PK 明细id  机动车抵押登记质押备案申请表
  		ARC001 50  PK 明细id  结清证明
	 	ARC001 60  PK 明细id  授权委托书
	  	ARC001 70  PK 明细id  所有权转让及解除抵押证明
	 */
	private Object saveUpload(Map map) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
		String fileNm = map.get("fileNm").toString();
		String filePath = map.get("filePath").toString();
		//String sysCd = request.getParameter("sysCd");
		//String orgCd = request.getParameter("orgCd");
		String cfgCd = map.get("cfgCd").toString();
		String cfgDtlCd = map.get("cfgDtlCd").toString();
		String tabNm =map.get("tabNm").toString();
		String pkId =map.get("pkId").toString();
		String fileRem="";//备注 存放支付表号
		if(map.containsKey("PAY_SCH_NO")){
			fileRem= map.get("PAY_SCH_NO").toString();
		}
		try {
			SysUlFilesRecVO sysUlFilesRecVO=new SysUlFilesRecVO();
			sysUlFilesRecVO.setTabNm(tabNm);
			sysUlFilesRecVO.setCrtTm(new Date());
			sysUlFilesRecVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
			sysUlFilesRecVO.setMdfTm(new Date());
			sysUlFilesRecVO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
			sysUlFilesRecVO.setIsDel(BaseConstant.IS_YESNO_NO);
			sysUlFilesRecVO.setFileRem(fileRem);
			sysUlFilesRecVO.setFileNm(fileNm);
			sysUlFilesRecVO.setPkId(pkId);
			sysUlFilesRecVO.setFilePath(filePath);
			sysUlFilesRecVO.setSysCd(CurrentThreadContext.getCurrentSysCd());
			sysUlFilesRecVO.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
			sysUlFilesRecVO.setCfgCd(cfgCd);
			sysUlFilesRecVO.setCfgDtlCd(cfgDtlCd);
			sysUlFilesRecVO.setAbsLocPath(PropertiesCacheUtils.getProperty(UploadConstant.UPLOAD_ROOT_PATH)+sysUlFilesRecVO.getFilePath());
			Long id=sysUlFilesRecService.add(sysUlFilesRecVO);
			sysUlFilesRecVO.setId(id);
			result.setData(sysUlFilesRecVO);
			BaseLogUtils.info(logger, "saveUploadRecord", "上传t.[id="+id+"] DATA:" + JSONObject.toJSONString(filePath), CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.error(logger, "saveUploadRecord", "上传t.DATA:" + JSONObject.toJSONString(filePath) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "saveUploadRecord", "上传t.DATA:" + JSONObject.toJSONString(filePath) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	/**
	 * 导出结清证明.doc
	 */
	@RequestMapping(value = "/settleProofWord.do")
	@ResponseBody
	public void settleProofWord(HttpServletRequest request, HttpServletResponse response,Map mmap) throws Exception {
		// 1 模板路径装载模板
		String templatePath = request.getSession().getServletContext()
				.getRealPath("/")
				+ "resource/template/warrant/";
		String fileName = "结清证明.doc";
		
		String vin="";
	    String vehNo="";
	    String contractNo="";
		if(mmap.containsKey("vin")){// 车架号
			vin=mmap.get("vin").toString();
		}
		if(mmap.containsKey("vehNo")){//支付表号
			vehNo=mmap.get("vehNo").toString();
		}
		if(mmap.containsKey("contractNo")){
			contractNo=mmap.get("contractNo").toString();
		}
		/* 数据 */
		Map<String, Object> dataMap = new HashMap<String, Object>();
		dataMap.put("hee", contractNo);
		dataMap.put("che", vehNo);
		dataMap.put("je", vin);

		Configuration configuration = new Configuration();
		configuration.setDefaultEncoding("utf-8");
		// dataMap 要填入模本的数据文件
		// configuration.setClassForTemplateLoading(this.getClass(),
		// "src/main/java/cn/fl/warrant/controller/");
		configuration.setDirectoryForTemplateLoading(new File(templatePath));
		Template t = null;
		try {
			// test.ftl为要装载的模板
			t = configuration.getTemplate("jieqing.ftl");
			// t = configuration.getTemplate("shou.ftl");
			// t = configuration.getTemplate("ya.ftl");
			// t = configuration.getTemplate("ji.ftl");
		} catch (IOException e) {
			e.printStackTrace();
		}
		/*// 2 开始导出word模板，通过浏览器导出
		// Writer out = null;
		Writer writer = response.getWriter();
		response.reset();// 清除首部的空白行
		fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");
		response.setContentType("application/msword;charset=UTF-8");
		response.setHeader("Content-Disposition", "attachment;filename="
				+ fileName);
		t.process(dataMap, writer);
		// writer.write(writer);
		writer.flush();
		writer.close();*/
		// 拼接存入路径-------->系统相对路径前缀 + 系统代码 + 模块(自定义) + 时间 + 文件
		JSONObject fileParams=uploadPath(fileName);
		//fileNm
		File pathFile = new File(fileParams.get("pathFile").toString());
		//检查目录
		if (!pathFile.exists()) {
			BaseLogUtils.info(logger, "uploadPath", "文件上传fileParams"+fileParams, CurrentThreadContext.getCurrentUserName());
			// 文件夹不存 创建文件
			boolean createPath = pathFile.mkdirs();
			if (!createPath) {
				BaseLogUtils.info(logger, "uploadPath", "文件上传B33, 创建文件目录失败!" + createPath, CurrentThreadContext.getCurrentUserName());
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "服务器附件目录未创建失败!");
			}
		}
		File outFile = new File(fileParams.get("pathFile").toString()+fileParams.get("uuidfileNm").toString());
		//输出
		Writer out = null;
		FileOutputStream fos = null;
		try {
			fos = new FileOutputStream(outFile);
			OutputStreamWriter oWriter = new OutputStreamWriter(fos, "UTF-8");
			// 这个地方对流的编码不可或缺，使用main（）单独调用时，应该可以，但是如果是web请求导出时导出后word文档就会打不开，并且包XML文件错误。主要是编码格式不正确，无法解析。
			// out = new BufferedWriter(new OutputStreamWriter(new
			// FileOutputStream(outFile)));
			out = new BufferedWriter(oWriter);
		} catch (FileNotFoundException e1) {
			e1.printStackTrace();
		}
		try {
			t.process(dataMap, out);
			out.close();
			fos.close();
		} catch (TemplateException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		//保存文件到数据库
		Map map =new HashMap();
		map.put("fileNm", fileParams.get("fileNm"));
		map.put("filePath", fileParams.get("filePath"));
		map.put("cfgCd", ArchiveConstants.ARC001);
		map.put("cfgDtlCd", ArchiveConstants.JIE_CFG_DTL_CD);
		map.put("tabNm", ArchiveConstants.TARANSFER_MAIN);
		map.put("pkId", mmap.get("pkId"));//后期记得改
		if(mmap.containsKey("PAY_SCH_NO")){
			map.put("PAY_SCH_NO", mmap.get("PAY_SCH_NO"));
		}
		saveUpload(map);
	}
	/**
	 * 导出授权委托书.doc
	 */
	@RequestMapping(value = "/attorneyWord.do")
	@ResponseBody
	public void attorneyWord(HttpServletRequest request, HttpServletResponse response,Map mmap) throws Exception {
		// 1 模板路径装载模板
		String templatePath = request.getSession().getServletContext()
				.getRealPath("/")
				+ "resource/template/warrant/";
		// session.getServletContext().getRealPath("/") +
		// "resource/template/capital/" + filename;
		String fileName = "授权委托书.doc";
		String vin="";
		if(mmap.containsKey("vin")){//车架号
			vin=mmap.get("vin").toString();
		}
		Map<String, Object> dataMap = new HashMap<String, Object>();
		dataMap.put("hap", vin);

		Configuration configuration = new Configuration();
		configuration.setDefaultEncoding("utf-8");
		// dataMap 要填入模本的数据文件
		configuration.setDirectoryForTemplateLoading(new File(templatePath));
		Template t = null;
		try {
			// shou.ftl为要装载的模板
			t = configuration.getTemplate("shou.ftl");
		} catch (IOException e) {
			e.printStackTrace();
		}
		/*// 2 开始导出word模板，通过浏览器导出
		// Writer out = null;
		Writer writer = response.getWriter();
		response.reset();// 清除首部的空白行
		fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");
		response.setContentType("application/msword;charset=UTF-8");
		response.setHeader("Content-Disposition", "attachment;filename="
				+ fileName);
		t.process(dataMap, writer);
		// writer.write(writer);
		writer.flush();
		writer.close();*/
		// 拼接存入路径-------->系统相对路径前缀 + 系统代码 + 模块(自定义) + 时间 + 文件
		JSONObject fileParams=uploadPath(fileName);
		//fileNm
		File pathFile = new File(fileParams.get("pathFile").toString());
		//检查目录
		if (!pathFile.exists()) {
			BaseLogUtils.info(logger, "uploadPath", "文件上传fileParams"+fileParams, CurrentThreadContext.getCurrentUserName());
			// 文件夹不存 创建文件
			boolean createPath = pathFile.mkdirs();
			if (!createPath) {
				BaseLogUtils.info(logger, "uploadPath", "文件上传B33, 创建文件目录失败!" + createPath, CurrentThreadContext.getCurrentUserName());
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "服务器附件目录未创建失败!");
			}
		}
		File outFile = new File(fileParams.get("pathFile").toString()+fileParams.get("uuidfileNm").toString());
		//输出
		Writer out = null;
		FileOutputStream fos = null;
		try {
			fos = new FileOutputStream(outFile);
			OutputStreamWriter oWriter = new OutputStreamWriter(fos, "UTF-8");
			// 这个地方对流的编码不可或缺，使用main（）单独调用时，应该可以，但是如果是web请求导出时导出后word文档就会打不开，并且包XML文件错误。主要是编码格式不正确，无法解析。
			// out = new BufferedWriter(new OutputStreamWriter(new
			// FileOutputStream(outFile)));
			out = new BufferedWriter(oWriter);
		} catch (FileNotFoundException e1) {
			e1.printStackTrace();
		}
		try {
			t.process(dataMap, out);
			out.close();
			fos.close();
		} catch (TemplateException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		//保存文件到数据库
		Map map =new HashMap();
		map.put("fileNm", fileParams.get("fileNm"));
		map.put("filePath", fileParams.get("filePath"));
		map.put("cfgCd", ArchiveConstants.ARC001);
		map.put("cfgDtlCd", ArchiveConstants.SHOU_CFG_DTL_CD);
		map.put("tabNm", ArchiveConstants.TARANSFER_MAIN);
		map.put("pkId", mmap.get("pkId"));//后期记得改
		if(mmap.containsKey("PAY_SCH_NO")){
			map.put("PAY_SCH_NO", mmap.get("PAY_SCH_NO"));
		}
		saveUpload(map);
	}
	/**
	 * 导出机动车抵押登记质押备案申请表.doc
	 */
	@RequestMapping(value = "/applyWord.do")
	@ResponseBody
	public void applyWord(HttpServletRequest request, HttpServletResponse response,Map mmap) throws Exception {
	
		String templatePath = request.getSession().getServletContext()
				.getRealPath("/")
				+ "resource/template/warrant/";
		String fileName = "机动车抵押登记质押备案申请表.doc";
		
		String vehNo="";
		if(mmap.containsKey("vehNo")){
			vehNo=mmap.get("vehNo").toString();
		}
		Map<String, Object> dataMap = new HashMap<String, Object>();
		dataMap.put("name", vehNo);

		Configuration configuration = new Configuration();
		configuration.setDefaultEncoding("utf-8");
		// dataMap 要填入模本的数据文件
		configuration.setDirectoryForTemplateLoading(new File(templatePath));
		Template t = null;
		try {
			// shou.ftl为要装载的模板
			t = configuration.getTemplate("ji.ftl");
		} catch (IOException e) {
			e.printStackTrace();
		}
		/*// 2 开始导出word模板，通过浏览器导出
		// Writer out = null;
		Writer writer = response.getWriter();
		response.reset();// 清除首部的空白行
		fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");
		response.setContentType("application/msword;charset=UTF-8");
		response.setHeader("Content-Disposition", "attachment;filename="
				+ fileName);
		t.process(dataMap, writer);
		// writer.write(writer);
		writer.flush();
		writer.close();*/
		// 拼接存入路径-------->系统相对路径前缀 + 系统代码 + 模块(自定义) + 时间 + 文件
		JSONObject fileParams=uploadPath(fileName);
		//fileNm
		File pathFile = new File(fileParams.get("pathFile").toString());
		//检查目录
		if (!pathFile.exists()) {
			BaseLogUtils.info(logger, "uploadPath", "文件上传fileParams"+fileParams, CurrentThreadContext.getCurrentUserName());
			// 文件夹不存 创建文件
			boolean createPath = pathFile.mkdirs();
			if (!createPath) {
				BaseLogUtils.info(logger, "uploadPath", "文件上传B33, 创建文件目录失败!" + createPath, CurrentThreadContext.getCurrentUserName());
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "服务器附件目录未创建失败!");
			}
		}
		File outFile = new File(fileParams.get("pathFile").toString()+fileParams.get("uuidfileNm").toString());
		//输出
		Writer out = null;
		FileOutputStream fos = null;
		try {
			fos = new FileOutputStream(outFile);
			OutputStreamWriter oWriter = new OutputStreamWriter(fos, "UTF-8");
			// 这个地方对流的编码不可或缺，使用main（）单独调用时，应该可以，但是如果是web请求导出时导出后word文档就会打不开，并且包XML文件错误。主要是编码格式不正确，无法解析。
			// out = new BufferedWriter(new OutputStreamWriter(new
			// FileOutputStream(outFile)));
			out = new BufferedWriter(oWriter);
		} catch (FileNotFoundException e1) {
			e1.printStackTrace();
		}
		try {
			t.process(dataMap, out);
			out.close();
			fos.close();
		} catch (TemplateException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		//保存文件到数据库
		Map map =new HashMap();
		map.put("fileNm", fileParams.get("fileNm"));
		map.put("filePath", fileParams.get("filePath"));
		map.put("cfgCd", ArchiveConstants.ARC001);
		map.put("cfgDtlCd", ArchiveConstants.DY_CFG_DTL_CD);
		map.put("tabNm", ArchiveConstants.TARANSFER_MAIN);
		map.put("pkId", mmap.get("pkId"));//后期记得改
		if(mmap.containsKey("PAY_SCH_NO")){
			map.put("PAY_SCH_NO", mmap.get("PAY_SCH_NO"));
		}
		saveUpload(map);
	}
	/**
	 * 根据交接单ID匹配一个交接单
	 * */
	public ArcTransferMainVO  initSettleReceiptById(String id,String contractNo,String paySchNo){
		
		ArcTransferMainVO mv=new ArcTransferMainVO();
		try{
			List<ArcTransferDetailVO> detailList=new ArrayList<ArcTransferDetailVO>();
			//筛选一个交接单
			ArcReceiptMainQueryCondition rqc=new ArcReceiptMainQueryCondition();
			if (StringUtils.isNotBlank(id)) {//交接单ID
				rqc.setId(id);
		}
		ArcReceiptMainVO receiptMainVo =  this.arcReceiptMainService.selectById(Long.parseLong(id));
		if (receiptMainVo!=null) {
			//交接单明细查询
			ArcReceiptDetailQueryCondition rdqc=new ArcReceiptDetailQueryCondition();
			rdqc.setArcReceiptMainId(receiptMainVo.getId());
			List<ArcReceiptDetailVO> arcReceiptDetailVOList = ArcReceiptDetailVOTransform.toVOList(this.arcReceiptMainService.arcReceiptDetailList(rdqc));
			for(int i=0;i<arcReceiptDetailVOList.size();i++) {//遍历交接单明细
				ArcReceiptDetailVO arcReceiptDetailVO = arcReceiptDetailVOList.get(i);
				ArcBscInfoVO arcBscInfoVO = arcBscInfoService.selectById(arcReceiptDetailVO.getArcBscInfo());
				String fileFlagNm="";
				if(arcBscInfoVO != null) {
					arcReceiptDetailVO.setWarrantName(arcBscInfoVO.getWarrantName());
					SysDictionaryDTO dictionary  = sysDictionaryApiService.getCode(ArchiveConstants.SYS_CODE, ArchiveConstants.ORG_CODE,
							ArchiveConstants.ARC001, arcBscInfoVO.getWarrantType());
					if(dictionary != null){
						fileFlagNm=dictionary.getCodeNm();
					}
				}
				//只匹配结清资料
				if (ArchiveConstants.FILE_FLAG_5.equals(arcBscInfoVO.getWarrantType())) {
					//交接单初始化一份
					{
						ArcTransferDetailVO dVo=new ArcTransferDetailVO();
						//dVo.setArcApplyMainId(mgrd.getArcApplyMainId());//归档申请主表ID
						dVo.setArcReceiptDetailId(arcReceiptDetailVO.getId());//交接单明细ID
						dVo.setContractNo(contractNo);//融资租赁合同编号
						dVo.setPaylistCode(paySchNo);//支付表号
						dVo.setFileFlag(arcBscInfoVO.getWarrantType());//权证类别(合同、权证资料等)[档案基础信息]
						dVo.setFileName(arcBscInfoVO.getWarrantName());//权证名称[档案基础信息]
						dVo.setArcLevel(arcBscInfoVO.getArcLevel());//归类级别(合同归类、支付表归类)[档案基础信息]
						dVo.setDossierTemp(arcReceiptDetailVO.getType());//1原件/2复印件/3电子[交接单明细] 
						dVo.setIschoice(arcReceiptDetailVO.getIschoice());//是否必选[交接单明细] 0必选 1 非必选
						dVo.setDossierCount(arcReceiptDetailVO.getFenshu());//要求份数[交接单明细]
						dVo.setTransferNumber(0L);//已移交份数
						//dVo.setDossierCountI(0L);//归档中份数
						//dVo.setDossierCountT(0L);//已归档份数
						
						//dVo.setEleId(mgrd.getEleId());//电子合同ID(从项目电子合同记录表查出)
						//dVo.setThisCount(mgrd.getDossierCount());//本次归档份数
						//dVo.setCheckCount(mgrd.getCheckCount());//权证审核份数
						dVo.setIsValid(1);//是否有效（1：是，0：否）（SYS0021）
						dVo.setIsDel(0);//是否删除（1：是，0：否）
						
						dVo.setFileFlagNm(arcBscInfoVO.getWarrantTypeNm());//权证类别(合同、权证资料等)[档案基础信息]
						dVo.setArcLevelNm(arcBscInfoVO.getArcLevelNm());//归类级别(合同归类、支付表归类)[档案基础信息]
						dVo.setDossierTempNm(arcReceiptDetailVO.getType());//1原件/2复印件/3电子[交接单明细] 
						dVo.setIschoiceNm(arcReceiptDetailVO.getIschoice());//是否必选[交接单明细] 0必选 1 非必选
						dVo.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
						dVo.setCrtTm(new Date());
						/*//区分合同，支付表
						if (arcBscInfoVO.getArcLevel().equals(ArchiveConstants.ARCLEVEL_2)) {
							dlist.add(dVo);
						}else {
							clist.add(dVo);
						}*/
						detailList.add(dVo);
					}//交接单初始化一份
				  }//只匹配结清资料
				}//遍历交接单明细
				
				//Long	arcReceiptMainId=list.get(0).getId();
				mv.setArcReceiptMainId(receiptMainVo.getId());
				mv.setArcReceiptName(receiptMainVo.getListName());
				mv.setVersioni(receiptMainVo.getVersion());
				mv.setArcTransferDetailList(detailList);
			}else {
				BaseLogUtils.error(logger, "initSettleReceiptById没找到交接单", "操作数据失败.DATA:" + JSONObject.toJSONString(paySchNo), CurrentThreadContext.getCurrentUserName());
			}
		}catch(Exception ex){
			ex.printStackTrace();
			/*result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());*/
			BaseLogUtils.error(logger, "initSettleReceiptById没找到交接单", "操作数据失败.DATA:" + JSONObject.toJSONString(paySchNo) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return 	mv	;			
	}
	/**
	 * 权证结清移交审核流程附加页面  基础资料邮寄(合同管理员)sign=01，基础资料邮寄(省公司)sign=02，签收单解押材料上传sign=03
	 *                       驳回发起人sign=06
	 */
	@RequestMapping(value = "/getFlowN.do", method = { RequestMethod.GET})
	public String getFlowN(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		// try {

		String id = request.getParameter("id");
		String flag = request.getParameter("flag");
		String sign = request.getParameter("sign");
		request.setAttribute("flag", flag);
		request.setAttribute("sign", sign);
		request.setAttribute("id", id);
		request.setAttribute("sysDate", DateUtils.formatDateToString(new Date(), DateUtils.YYYY_MM_DD));
		request.setAttribute("loginUsrNm", CurrentThreadContext.getCurrentUserName());
		request.setAttribute("prefixUrl",PropertiesCacheUtils.getProperty(SysUlFilesRecConstant.SYS_FILE_UPLOAD_SERVER_PATH));
		// 查找申请单
		if(StringUtils.isNotBlank(id)){
		}else{
			return "archive/arcTransferMain/arcTransferFlowN";
		}
		//解押材料申请表附件地址
		SysUlFilesRecVO rec = new SysUlFilesRecVO();
		SysUlFilesRecQueryCondition qqc = new SysUlFilesRecQueryCondition();
		qqc.setPkId(id);
		qqc.setCfgDtlCd(ArchiveConstants.SHEN_CFG_DTL_CD);
		qqc.setCfgCd(ArchiveConstants.ARC001);
		qqc.setTabNm(ArchiveConstants.TARANSFER_MAIN);
		qqc.setSysCd(CurrentThreadContext.getCurrentSysCd());//系统代码-必须条件
		List<SysUlFilesRecVO> flist=sysUlFilesRecService.searchList(qqc);
		if(flist!=null && flist.size()>0){
			if(StringUtils.isNotEmpty(flist.get(0).getFilePath())){
				request.setAttribute("up_file_id", flist.get(0).getId());
				request.setAttribute("jie_up_file_path", flist.get(0).getFilePath());
			};
		}///附件
		//签收单附件
		SysUlFilesRecVO rec1 = new SysUlFilesRecVO();
		SysUlFilesRecQueryCondition qqc1 = new SysUlFilesRecQueryCondition();
		qqc1.setPkId(id);
		qqc1.setCfgDtlCd(ArchiveConstants.QIAN_CFG_DTL_CD);
		qqc1.setCfgCd(ArchiveConstants.ARC001);
		qqc1.setTabNm(ArchiveConstants.TARANSFER_MAIN);
		qqc1.setSysCd(CurrentThreadContext.getCurrentSysCd());//系统代码-必须条件
		List<SysUlFilesRecVO> flist1=sysUlFilesRecService.searchList(qqc1);
		if(flist1!=null && flist1.size()>0){
			if(StringUtils.isNotEmpty(flist1.get(0).getFilePath())){
				request.setAttribute("receipt_file_id", flist1.get(0).getId());
				request.setAttribute("receipt_up_file_path", flist1.get(0).getFilePath());
			};
		}//签收单
		
		ArcTransferMainVO avo = this.arcTransferMainService.selectById(Long
				.valueOf(id));
		// avo.setArcApplyDetailList(aList);
		request.setAttribute("avo", avo);
		String syscd = CurrentThreadContext.getCurrentSysCd();
		String orgcd = CurrentThreadContext.getCurrentOrgCd();
		request.setAttribute("sendTypeList", this.sysDictionaryApiService
				.getKvList(ArchiveConstants.ARC010, syscd, orgcd));// 接收方式
		request.setAttribute("sendCompanyList", this.sysDictionaryApiService
				.getKvList(ArchiveConstants.ARC012, syscd, orgcd));// 接收方式
		// 邮寄信息
		List<ArcPostInfoVO> plist = new ArrayList<ArcPostInfoVO>();
		ArcPostInfoQC condition2 = new ArcPostInfoQC();
		condition2.setArcAppId(Long.valueOf(id));
		plist = this.arcPostInfoService.searchList(condition2);
		//modify by gengchunlan 20191012
		ArcPostInfoVO currentPost =new ArcPostInfoVO();//当前节点邮寄信息
		ArcPostInfoVO cstMgrPost =new ArcPostInfoVO();//客户经理邮寄信息
		// 初始化
		if (plist != null) {
			for (int i = 0; i < plist.size(); i++) {
				ArcPostInfoVO post = plist.get(i);

				// 省合同管理员商助
				if ("002".equals(sign) && "2".equals(post.getSendPorsonType())) {
					request.setAttribute("post", post);
					currentPost=post;
					plist.remove(i);
					break;
				}
				// 总公司邮件
				if ("001".equals(sign) && "3".equals(post.getSendPorsonType())) {
					request.setAttribute("post", post);
					currentPost=post;
					plist.remove(i);
					break;
				}
				//客户经理邮寄sign
				if ("006".equals(sign) && "1".equals(post.getSendPorsonType())) {
					request.setAttribute("post", post);
					currentPost=post;
					plist.remove(i);
					break;
				}
				if("1".equals(post.getSendPorsonType())) {//客户经理邮寄信息
					cstMgrPost=post;
				}
			}
		}
		request.setAttribute("plist", plist);
		if(null ==currentPost.getArcAppId()) {//默认带出申请人邮寄信息
			ArcPostInfoVO cPost =new ArcPostInfoVO();//
			cPost.setSendAddr(cstMgrPost.getSendAddr());//邮寄地址
			cPost.setSendNum(cstMgrPost.getSendNum());//快递单号
			cPost.setSendCompany(cstMgrPost.getSendCompany());//快递公司
			cPost.setRecipient(cstMgrPost.getRecipient());//收件人（姓名）
			cPost.setIdCard(cstMgrPost.getIdCard()); //收件人工号recipient
			cPost.setMobile(cstMgrPost.getMobile());//联系电话
			request.setAttribute("post", cPost);
		}
		BaseLogUtils.info(logger, "getFlowN", "跳转到列表页面.",
				CurrentThreadContext.getCurrentUserName());

		// } catch (Exception e) {
		// // TODO: handle exception
		// BaseLogUtils.error(logger, "getFlow", e.getMessage(),
		// CurrentThreadContext.getCurrentUserName());
		// }
		return "archive/arcTransferMain/arcTransferFlowN";
	}
	/**
	 * 权证结清移交审核 到流程列表页面 回传 权证归档结清材料sign=04 解押材料盖章并邮寄sign=05
	 */
	@RequestMapping(value = "/getFlowNHC.do", method = { RequestMethod.GET})
	public String getFlowNHC(HttpServletRequest request, HttpServletResponse response) {
		try {
			
			String id = request.getParameter("id");
			String flag = request.getParameter("flag");
			String sign = request.getParameter("sign");
			request.setAttribute("flag",flag);
			request.setAttribute("id",id);
			request.setAttribute("sign",sign);
			//查找申请单
			ArcTransferMainVO avo= this.arcTransferMainService.selectById(Long.valueOf(id));
			request.setAttribute("avo",avo);
			//avo.setArcApplyDetailList(aList);
			String syscd = CurrentThreadContext.getCurrentSysCd(); 
			String orgcd = CurrentThreadContext.getCurrentOrgCd();
			request.setAttribute("sendTypeList", this.sysDictionaryApiService.getKvList(ArchiveConstants.ARC010,syscd,orgcd));//接收方式
		
			/*//申请单明细
			ArcTransferDetailQueryCondition dQc=new ArcTransferDetailQueryCondition();
			dQc.setArcTransferMainId(Long.valueOf(id));
			List<ArcTransferDetailVO> dList=this.arcTransferDetailService.searchList(dQc);
			request.setAttribute("dList",dList);
			//档案明细，归档表
			String paySchNo=avo.getPaySchNo();
			ArcMgrMainQC qc=new ArcMgrMainQC();
			qc.setPaySchNo(paySchNo);
			List<ArcMgrMainVO> mgrList=this.arcMgrMainService.selectList(qc);
			for (int i = 0; i < mgrList.size(); i++) {
				ArcMgrMainVO vo=mgrList.get(i);
				ArcMgrDetailQC mdqc=new ArcMgrDetailQC();
				mdqc.setArcMgrMainId(vo.getId());
				List<ArcMgrDetailVO> ppList=this.arcMgrDetailService.searchList(mdqc);//支付表明细
				if (ppList!=null) {
					//去除结清资料
					for (int j = 0; j < ppList.size(); j++) {
						ArcMgrDetailVO dvo=ppList.get(j);
						if (ArchiveConstants.FILE_FLAG_5.equals(dvo.getFileFlag())) {
								ppList.remove(dvo);
								--j;
						}
					}
				}
				vo.setArcMgrDetailList(ppList);
			}
			request.setAttribute("paySchNo",paySchNo);
			request.setAttribute("mgr",avo);
			request.setAttribute("mgrList",mgrList);*/
			request.setAttribute("sendCompanyList", this.sysDictionaryApiService
					.getKvList(ArchiveConstants.ARC012, syscd, orgcd));// 接收方式
			//邮寄信息
			List<ArcPostInfoVO> plist=new ArrayList<ArcPostInfoVO>();		
			ArcPostInfoQC condition2=new ArcPostInfoQC();
			condition2.setArcAppId(Long.valueOf(id));
			plist=this.arcPostInfoService.searchList(condition2);
			//modify by gengchunlan 20191012
			ArcPostInfoVO currentPost =new ArcPostInfoVO();//当前节点邮寄信息
			ArcPostInfoVO cstMgrPost =new ArcPostInfoVO();//客户经理邮寄信息
			// 初始化
			if (plist != null) {
				for (int i = 0; i < plist.size(); i++) {
					ArcPostInfoVO post = plist.get(i);
					//北京权证室sign
					if ("005".equals(sign) && "4".equals(post.getSendPorsonType())) {
						request.setAttribute("post", post);
						currentPost=post;
						plist.remove(i);
						break;
					}
					if("1".equals(post.getSendPorsonType())) {//客户经理邮寄信息
						cstMgrPost=post;
					}
				}
			}
			request.setAttribute("plist",plist);
			if(null ==currentPost.getArcAppId()) {//默认带出申请人邮寄信息
				ArcPostInfoVO cPost =new ArcPostInfoVO();//
				cPost.setSendAddr(cstMgrPost.getSendAddr());//邮寄地址
				cPost.setSendNum(cstMgrPost.getSendNum());//快递单号
				cPost.setSendCompany(cstMgrPost.getSendCompany());//快递公司
				cPost.setRecipient(cstMgrPost.getRecipient());//收件人（姓名）
				cPost.setIdCard(cstMgrPost.getIdCard()); //收件人工号recipient
				cPost.setMobile(cstMgrPost.getMobile());//联系电话
				request.setAttribute("post", cPost);
			}
			BaseLogUtils.info(logger, "getFlowNHC", "跳转到列表页面.", CurrentThreadContext.getCurrentUserName());

		} catch (Exception e) {
			// TODO: handle exception
			BaseLogUtils.error(logger, "getFlowNHC", e.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return "archive/arcTransferMain/arcTransferFlowHCN";
		
	}
	/**
	 * 修改流程修改
	 */
	@RequestMapping(value = "/modifyFlowN.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object modifyFlowN(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		String up_file_id = request.getParameter("up_file_id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "modifyFlow", "修改数据,主键不存在.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		
	try {
		Map map=this.getParms(request);
		//查找申请单
		ArcTransferMainVO avo= this.arcTransferMainService.selectById(Long.valueOf(id));
		String sign = request.getParameter("sign");
		String flag = request.getParameter("flag");
		String griddata1 = request.getParameter("griddata1");//权证资料明细
		String griddata2 = request.getParameter("griddata2");//结清资料明细
		avo.setMdfUsrId(new Long(sign));
		this.arcTransferMainService.update(avo);
		if(null != griddata1 ){//权证资料
			List grid1List = JSONArray.fromObject(griddata1);//权证资料
			//权证资料  省公司  总部
			if(null!=sign && !"".equals(sign) && ("001".equals(sign)||"002".equals(sign) )){//实际移交份数
			   if(grid1List!=null && grid1List.size()>0){
					for(int k=0;k<grid1List.size();k++){
						net.sf.json.JSONObject jsonobj = (net.sf.json.JSONObject) grid1List.get(k); // 遍历 jsonarray 数组，把每一个对象转成 json 对象
						if(jsonobj.get("id")!=null && !"".equals(jsonobj.get("id"))){
								ArcMgrDetailVO detailVo= new ArcMgrDetailVO();
								detailVo.setId(Long.parseLong(jsonobj.getString("id")));
								detailVo.setMdfTm(new Date());
								detailVo.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
								if(jsonobj.containsKey("transferCount")){
									if(jsonobj.getString("transferCount") == null || "null".equals(jsonobj.getString("transferCount"))){
										detailVo.setTransferCount(Long.parseLong(jsonobj.getString("dossierCountT")));
										arcMgrDetailService.modify(detailVo);
									}else{
										detailVo.setTransferCount(Long.parseLong(jsonobj.getString("transferCount")));
										arcMgrDetailService.modify(detailVo);
									}
								}	
						}
					}
				}
			}//end //权证资料  省公司  总部
		}//end 权证资料
		if(null != griddata2 ){// 结清资料
			List grid2List = JSONArray.fromObject(griddata2);//权证资料
			if(grid2List!=null && grid2List.size()>0){
				for(int k=0;k<grid2List.size();k++){
					net.sf.json.JSONObject jsonobj = (net.sf.json.JSONObject) grid2List.get(k); // 遍历 jsonarray 数组，把每一个对象转成 json 对象
					if(jsonobj.get("id")!=null && !"".equals(jsonobj.get("id"))){
						//sign==sign=003结清资料
						if(null!=sign && !"".equals(sign) && "003".equals(sign)){//结清资料
							ArcTransferDetailVO tVo= new ArcTransferDetailVO();
							tVo.setId(Long.parseLong(jsonobj.getString("id")));
							tVo.setMdfTm(new Date());
							tVo.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
							if(jsonobj.containsKey("transferNumber")){
								if(jsonobj.getString("transferNumber") == null || "null".equals(jsonobj.getString("transferNumber"))){
									tVo.setTransferNumber(Long.parseLong(jsonobj.getString("dossierCount")));
									arcTransferDetailService.modify(tVo);
								}else{
									tVo.setTransferNumber(Long.parseLong(jsonobj.getString("transferNumber")));
									arcTransferDetailService.modify(tVo);
								}
							}
						}//sign==sign=003结清资料
					}
				}
			}
		}//end 结清资料
		//保存邮寄信息
		ArcPostInfoVO pVo=new ArcPostInfoVO();
		pVo.setArcAppId(Long.valueOf(id));
		//保存邮寄信息
		map.put("arcAppId", id);
		map.put("arcAppType", "3");
		if("002".equals(sign)){
			//省公司邮寄
			map.put("sendPorsonType", "2");
			map.put("arcAppBussType", "2");
		}else if("001".equals(sign)) {
			//总公司邮寄
			map.put("sendPorsonType", "3");
			map.put("arcAppBussType", "3");
		}else if("006".equals(sign)){//发起人修改
			//客户经理邮寄
			map.put("sendPorsonType", "1");
			map.put("arcAppBussType", "1");
		}else if("005".equals(sign)){//北京权证室
			map.put("sendPorsonType", "4");
			map.put("arcAppBussType", "6");
		}
		this.arcPostInfoService.addOrUpdate(map);
		
		BaseLogUtils.info(logger, "modifyFlow", "修改成功.[id="+id+"] DATA:" + JSONObject.toJSONString(avo), CurrentThreadContext.getCurrentUserName());
	}catch (BaseException ex) {
		result.setSuccess(BaseConstant.IS_YESNO_NO);
		result.setInfo(ex.getMessage());
		BaseLogUtils.info(logger, "modifyFlow", "修改失败.[id="+id+"] DATA:"  + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
	}catch (Exception ex) {
		result.setSuccess(BaseConstant.IS_YESNO_NO);
		result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
		BaseLogUtils.error(logger, "modifyFlow", "修改失败.[id="+id+"] DATA:"  + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
	}
	return result;
	}
	/**
	 * 签收单及解押材料下载批量打包下载
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/batchDownload.do")
    public ModelAndView batchDownload(HttpServletRequest request, HttpServletResponse response) {
		
		String pNo = null;//流程号
		String applyId = request.getParameter("applyId");//流程业务主键id（移交申请id）
		String sign = request.getParameter("sign");//下载解押材料(005) 签收单及解押材料下载(004)
		if(StringUtils.isNotBlank(applyId)) {
			Pager page = new Pager();
			ArcTransferMainQueryCondition qc = new ArcTransferMainQueryCondition();
			qc.setParentId(Long.valueOf(applyId));
	        page.setCondition(qc);
	        List<ArcSysFlowSHVO> plist=this.arcTransferMainService.searchFlow(qc);
	        if(plist != null && plist.size()>0) {
	        	ArcSysFlowSHVO flowSHVO = plist.get(0);
	        	pNo = flowSHVO.getpNo();
	        }
		}
		String tmpZipFileName = "";//压缩包名称
		if(StringUtils.isNotBlank(pNo)) {
			tmpZipFileName += pNo;
		}
		tmpZipFileName += ".zip";
        
        try {
            byte[] buffer = new byte[1024];
            ZipOutputStream out = new ZipOutputStream(response.getOutputStream());

            response.setContentType("application/x-msdownload;");
            response.setHeader("Content-Disposition", "attachment; filename=" + new String( tmpZipFileName.getBytes("UTF-8"), "ISO8859-1" )  );
            request.setCharacterEncoding("UTF-8");

            List<String> list = new ArrayList<String>();//下载文件列表
            Map<String, Integer> map = new HashMap<String, Integer>();
            List<SysUlFilesRecDTO> sysUlFilesRecDTOS=new ArrayList<SysUlFilesRecDTO>();//下载zip所有文件
            //获取签收单 
            if(sign!=null && !"".equals(sign)&& "004".equals(sign)){
            	 SysUlFilesRecQueryCondition condition = new SysUlFilesRecQueryCondition();
                 condition.setPkId(applyId);
                 condition.setCfgCd(ArchiveConstants.ARC001);
                 condition.setCfgDtlCd(ArchiveConstants.QIAN_CFG_DTL_CD);
                 condition.setTabNm(ArchiveConstants.TARANSFER_MAIN);
                 condition.setSysCd(CurrentThreadContext.getFlServiceSysCd());
                 List<SysUlFilesRecDTO> qList = this.uploadApiService.searchSysUlFilesRecList(condition);
                 if(qList!=null && qList.size()>0){
                	 sysUlFilesRecDTOS.addAll(qList);
                 }
            }
            //解押材料
            if(sign!=null && !"".equals(sign)&& "005".equals(sign)){
            	 SysUlFilesRecQueryCondition condition = new SysUlFilesRecQueryCondition();
                 condition.setPkId(applyId);
                 condition.setCfgCd(ArchiveConstants.ARC001);
                 condition.setCfgDtlCd(ArchiveConstants.SHEN_CFG_DTL_CD);
                 condition.setTabNm(ArchiveConstants.TARANSFER_MAIN);
                 condition.setSysCd(CurrentThreadContext.getFlServiceSysCd());
                 List<SysUlFilesRecDTO> jList = this.uploadApiService.searchSysUlFilesRecList(condition);
                 if(jList!=null && jList.size()>0){
                	 sysUlFilesRecDTOS.addAll(jList);
                 }
            }
            ArcTransferMainQueryCondition qqc = new ArcTransferMainQueryCondition();
            qqc.setParentId(Long.parseLong(applyId));
        	List<ArcTransferMainVO> trMain = this.arcTransferMainService.searchListByCondition(qqc, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
            //获取结清证明”、“机动车抵押登记/质押备案申请表 ”、“所有权转让及解除抵押证明”、“授权委托书” applyId
            if(sign!=null && !"".equals(sign)&& "005".equals(sign)){
            	List<ArcMgrMainVO> mgrList =new ArrayList<ArcMgrMainVO>();
                List<SysUlFilesRecDTO> upfileList=new ArrayList<SysUlFilesRecDTO>();
            	if(null!=trMain && trMain.size()>0){
            		for(ArcTransferMainVO mv:trMain){
            			SysUlFilesRecQueryCondition fc = new SysUlFilesRecQueryCondition();
            			fc.setPkId(String.valueOf(mv.getId()));
            			fc.setSysCd(CurrentThreadContext.getFlServiceSysCd());
            			List<SysUlFilesRecDTO> linList=this.uploadApiService.searchSysUlFilesRecList(fc);
            			if(linList!=null && linList.size()>0) {
            				upfileList.addAll(linList);
            			}
            			//根据支付表号
            			if(StringUtils.isNotBlank(mv.getPaySchNo())){
            				ArcMgrMainQC mqc=new ArcMgrMainQC();
            				mqc.setPaySchNo(mv.getPaySchNo());
                			List<ArcMgrMainVO> mgrLin=this.arcMgrMainService.selectList(mqc);
                			mgrList.addAll(mgrLin);
            			}
            			
            		}
            	}//end if
            	if(upfileList!=null && upfileList.size()>0) {
            		sysUlFilesRecDTOS.addAll(upfileList);
            	}
            	//支付表其他资料查询
            	if(mgrList!=null && mgrList.size()>0){
            		for(ArcMgrMainVO mgr:mgrList){
            			SysUlFilesRecQueryCondition fc = new SysUlFilesRecQueryCondition();
            			fc.setPkId(String.valueOf(mgr.getId()));
            			fc.setSysCd(CurrentThreadContext.getFlServiceSysCd());
            			fc.setCfgDtlCd(ArchiveConstants.OTH_CFG_DTL_CD);
            			List<SysUlFilesRecDTO> mgrlin=this.uploadApiService.searchSysUlFilesRecList(fc);
            			if(null!=mgrlin && mgrlin.size()>0){
            				sysUlFilesRecDTOS.addAll(mgrlin);
            			}
            		}
            		
            	}//end 支付表其他资料
            }
        	//结清扫描件下载 //获取上传的扫描件文件列表
       		if(sign!=null && !"".equals(sign)&& "004".equals(sign)){
       			List<SysUlFilesRecDTO> scanAttcheList =new ArrayList<SysUlFilesRecDTO>();
	         	if(null!=trMain && trMain.size()>0){
	         	   for(ArcTransferMainVO mv:trMain){
	         		   ArcTransferDetailQueryCondition dc=new ArcTransferDetailQueryCondition();
	         		   if(StringUtils.isNotBlank(mv.getId().toString())){
	         			   dc.setArcTransferMainId(mv.getId());
	         			   List<ArcTransferDetailVO> dList=this.arcTransferDetailService.searchList(dc);
	 	   	        		for(int i=0;i<dList.size();i++){
	 	   	        			ArcTransferDetailVO  deVo=dList.get(i);
	 	   	        			if(deVo.getEleId()!=null){
	 	   	        				SysUlFilesRecQueryCondition sfqc = new SysUlFilesRecQueryCondition();//文件
	 	   	        				//设置公共属性
	 	   	        				sfqc.setPkId(deVo.getEleId().toString());
	 	   	        				//系统代码
	 	   	        				sfqc.setSysCd(CurrentThreadContext.getFlServiceSysCd());
	 	   	        			    List<SysUlFilesRecDTO> filesList = this.uploadApiService.searchSysUlFilesRecList(sfqc);//扫描件集合
	 	   	        				if(CollectionUtils.isNotEmpty(filesList) && filesList.size()>0){
	 	   	        					for(int j=0;j<filesList.size();j++){//下载
	 	   	        						SysUlFilesRecDTO recVo=filesList.get(j);
	 	   	        						recVo.setFileRem(mv.getPaySchNo());
	 	   	        						scanAttcheList.add(recVo);
	 	   	        					}
	 	   	        				}
	 	   	        			}
	 	   	        		}  
	         		   } 
	         	   }	
	         	   
	         	}//结清扫描件end
	         	if(scanAttcheList!=null && scanAttcheList.size()>0){
	         		sysUlFilesRecDTOS.addAll(scanAttcheList);
	         	}
       		}
        	
            for (int i = 0; i < sysUlFilesRecDTOS.size(); i++) {
                SysUlFilesRecDTO sysUlFilesRecDTO = sysUlFilesRecDTOS.get(i);
                String fileName = sysUlFilesRecDTO.getFileNm() != null ? sysUlFilesRecDTO.getFileNm() : sysUlFilesRecDTO.getDatNm();
                String subFileName = sysUlFilesRecDTO.getFileRem() != null ? sysUlFilesRecDTO.getFileRem() : sysUlFilesRecDTO.getPkId();

                FileInputStream fis = null;
                try {
                    fis = new FileInputStream(sysUlFilesRecDTO.getAbsLocPath());
                    if (list.contains(fileName)) {
                        map.put(fileName, map.get(fileName) + 1);
                        fileName = fileName.replace(".", "(" + map.get(fileName) + ").");
                    } else {
                        map.put(fileName, 0);
                    }
                    if(ArchiveConstants.SHEN_CFG_DTL_CD.contentEquals(sysUlFilesRecDTO.getCfgDtlCd())){
                    	fileName = "解押材料申请表" +File.separator+ fileName;
                    }else if(ArchiveConstants.QIAN_CFG_DTL_CD.contentEquals(sysUlFilesRecDTO.getCfgDtlCd())){
                    	fileName = "签收单" +File.separator+ fileName;
                    }else {
                    	fileName = subFileName +File.separator+ fileName;
                    }
                    
                    out.putNextEntry(new ZipEntry(fileName));
                    //下载的文件名写入list
                    list.add(fileName);
                    int bytesRead;
                    while (-1 != (bytesRead = fis.read(buffer, 0, buffer.length))) {
                        out.write(buffer, 0, bytesRead);
                    }
                } catch (Exception e) {
                	e.printStackTrace();
                    BaseLogUtils.error(logger, "batchDownload", "下载打包文件循环中失败!" + applyId, e);
                } finally {
                    if (null != out) {
                        out.flush();
                        out.closeEntry();
                    }
                    if (null != fis) {
                        fis.close();
                        fis = null;
                    }
                }
            }
            if (null != out) {
                out.finish();
                out.close();
                out = null;
            }
        } catch (Exception e) {
        	e.printStackTrace();
            BaseLogUtils.error(logger, "batchDownload", "下载打包文件失败!", e);
        }
        return null;
    }
	/**
	 * 到上传文件页面
	 */
	@RequestMapping(value = "/toUpload.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toUpload(HttpServletRequest request, HttpServletResponse response) {
		String id = request.getParameter("id");//权证资料明细id
		String paySchNo = request.getParameter("paySchNo");//支付表号 
	
		ModelAndView view = new ModelAndView("archive/arcTransferMain/arcTransferUpload");
		view.addObject("id", id);
		view.addObject("paySchNo", paySchNo);
		BaseLogUtils.info(logger, "toUpload", "跳转到页面.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
		return view;
	}
	//校验是否开启移交自动生成合同  1 关闭  2开启
	private String isCheckAutoContractFlag() {
		String flag = "1";
		List<SysDictionaryDTO> sysDictionaryDTOList = this.sysDictionaryApiService.searchGroup(CurrentThreadContext.getCurrentSysCd(),CurrentThreadContext.getCurrentOrgCd(), "ARC021");
		if (sysDictionaryDTOList != null && sysDictionaryDTOList.size() > 0) {
			for (SysDictionaryDTO sysDictionaryDTO : sysDictionaryDTOList) {
				if ("2".equals(sysDictionaryDTO.getCode())) {
					flag="2";
				}
			}
		}
		return flag;
	}
	/**
	 * 校验发起移交流程 /1 核查该支付表下有未归还权证资料，请先结束流程  2 //校验客户是否有小贷逾期，YQ等情况
	 */
	@RequestMapping(value = "/checkStartProcessBatch.do")
	@ResponseBody
	public Object checkStartProcessBatch(HttpServletRequest request, HttpServletResponse response) {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_NO, SysLogConstant.LOG_CMM_OPERATE_FAIL);
		int res=0;//re=1 1 核查该支付表下有未归还权证资料，请先结束流程  2 客户是否有小贷
		String payIdList = request.getParameter("payIdList");//支付表id字符串
		BaseLogUtils.info(logger, "checkStartProcessBatch", "移交校验===payIdList："+JSONObject.toJSONString(payIdList), CurrentThreadContext.getCurrentUserName());
		try {
			ArcTransferMainQueryCondition qc=new ArcTransferMainQueryCondition();
			Pager page = new Pager();
			page.setEveryPage(50); //设置成50，否则默认10条，有问题（modify by JL at 20190809）
			if(StringUtils.isNotEmpty(payIdList)){
				qc.setPayIdList(payIdList);
				page.setCondition(qc);
				Pager pager = this.arcTransferMainService.selectListForListPage(page);
				List<ArcTransferMainVO> list =ArcTransferMainVOTransform.toVOList((List<ArcTransferMainDTO>) pager.getResultList());
				if(CollectionUtils.isNotEmpty(list) && list.size()>0){ //加非空判断和日志（modify by JL at 20190809）
					BaseLogUtils.info(logger, "checkStartProcessBatch", "移交校验===transferList："+JSONObject.toJSONString(list), CurrentThreadContext.getCurrentUserName());
					//根据支付表号查询是否有未归还的权证资料
					for(ArcTransferMainVO vo:list){
						//校验核查该支付表下有未归还权证资料，请先结束流程
						ArcMgrDetailQC dqc = new ArcMgrDetailQC();
						dqc.setContractNo(vo.getContractNo());
						dqc.setPaylistCode(vo.getPaySchNo());
						dqc.setIsDel(ArchiveConstants.IS_DEL);//未删除
						dqc.setArcLevel("2");//归档级别：1 合同类  2 支付表类
						dqc.setFileFlag("3");//权证类别
						List<ArcMgrDetailVO> mgrList = this.arcMgrDetailService.searchList(dqc);
						BaseLogUtils.info(logger, "checkStartProcessBatch", "移交校验===mgrList："+JSONObject.toJSONString(mgrList), CurrentThreadContext.getCurrentUserName());
						if(CollectionUtils.isNotEmpty(mgrList) && mgrList.size()>0){ //加非空判断（modify by JL at 20190809）
							for(ArcMgrDetailVO de:mgrList){
								if(de.getBorrowStatus()!=null && !"".equals(de.getBorrowStatus()) && "1".equals(de.getBorrowStatus())){
									res=1;
									result.setData(res);
									result.setInfo(vo.getPaySchNo()+"支付表下有未归还权证资料，请先结束流程");
									return result;
								}
							}//end 校验核查该支付表下有未归还权证资料，请先结束流程
						}
					}
				}else{
					BaseLogUtils.info(logger, "checkStartProcessBatch", "移交校验.获取档案归档列表为空！"+JSONObject.toJSONString(list), CurrentThreadContext.getCurrentUserName());
				}
			}
			List<String> idList = Arrays.asList(payIdList.split(","));
			List<Long> idLongList = new ArrayList<Long>();
			BaseLogUtils.newServiceLogger("checkStartProcessBatch===idList:" +JSONObject.toJSONString(idList)).info();
			for(String schId : idList){
				if(StringUtils.isNotBlank(schId)){
					idLongList.add(Long.parseLong(schId));
				}
			}
			BaseLogUtils.newServiceLogger("checkStartProcessBatch===idLongList:" +JSONObject.toJSONString(idLongList)).info();
			//校验客户是否有小贷未结清 REQ-10566 判断是否存在未结清车抵贷YQ项目
			DataResultDTO re = this.mcrCstCrLimApiService.jycheckBatch(idLongList);
			BaseLogUtils.info(logger, "checkStartProcess", "小贷校验.idLongList="+JSONObject.toJSONString(idLongList)+"; re="+JSONObject.toJSONString(re), CurrentThreadContext.getCurrentUserName());
			if(re!=null && re.getCode()!=null && !"1".equals(re.getCode())){
				res=2;
				result.setData(res);
				result.setInfo(re.getInfo());
				return result;
			}
			result.setData("0");
		}catch(Exception ex) {
			result.setData("2");
			result.setInfo(ex.getMessage());
			BaseLogUtils.error(logger, "checkStartProcess", "获取-失败."+ex.getMessage()+payIdList, CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
	/**
	 * 批量导入移交申请数据
	 * @throws Exception 
	 */
	@RequestMapping(value = "/importBatchTransfer.do")
	@ResponseBody
	public Object importBatchTransfer(@RequestParam(value = "upfile") MultipartFile upfile, HttpServletRequest request) throws Exception {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "导入成功");
		if (null == upfile) { 
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("模板文件为空,请选择文件");
			BaseLogUtils.info(logger, "addFlowStart", SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY, CurrentThreadContext.getCurrentUserName());
			return result; 
        }
		String fileName = upfile.getOriginalFilename();//report.xls 
        String[] names=fileName.split("\\.");
        if(!names[names.length-1].toLowerCase().equals("xls")){
        	result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("请下载模板，然后填写数据!!");
			BaseLogUtils.info(logger, "addFlowStart", SysLogConstant.LOG_CMM_ENABLE_FAIL, CurrentThreadContext.getCurrentUserName());
			return result; 
        }
        InputStream fis = upfile.getInputStream();  
        result = this.parseExcel(fis,result);  // * 成功失败标识  1成功  0失败
        int  re=result.getSuccess();// * 成功失败直接返回前台提示信息
        if(re==0){
        	return result;
        }
        //解析到的数据 
        HttpSession session = request.getSession();
        BaseLogUtils.newServiceLogger("importBatchTransfer===解析到Excel paySchNoList:" +JSONObject.toJSONString(result.getData())).info();
        Map map = (Map)result.getData();
        int num=(int) map.get("num");
        String paySchNoString=map.get("paySchCds").toString();
        String zpaySchNoString ="";//最终校验支付表集合
        String notPassPaySchNoString="";//不合格支付表集合(归档状态不符合)
        String notPassPaySchNoString2="";//不合格支付表集合(移交分类不符合)
        String transferType="";//移交分类不可混选 transferType=1提前借出省公司保管'; transferType=2 正常借出结清
        //校验是否归档
        //是否属于结清移交列表数据
    	ArcTransferMainQueryCondition qc=new ArcTransferMainQueryCondition();
		Pager page = new Pager();
		page.setEveryPage(40);
    	qc.setPaySchNoList(paySchNoString);
		page.setCondition(qc);
		Pager pager = this.arcTransferMainService.selectListForListPage(page);
		List<ArcTransferMainVO> list =ArcTransferMainVOTransform.toVOList((List<ArcTransferMainDTO>) pager.getResultList());
		BaseLogUtils.newServiceLogger("importBatchTransfer===查询list :" +JSONObject.toJSONString(list)).info();
    	if(CollectionUtils.isEmpty(list)) {
    		result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("上传的EXCEL中支付表编号不存在移交列表数据，请核查!!");
			return result;
    	}
    	int cu=list.size();
    	String querypayNoList="";
    	if(num!=cu) {//比对列表数据，提示重复，校验不合规的数据
    		for(ArcTransferMainVO transferObj :list) {
    			if("".equals(querypayNoList)){
    				querypayNoList =  "'" + transferObj.getPaySchNo() + "'";
        		}else{
        			querypayNoList += ",'" + transferObj.getPaySchNo() + "'";
        		}
    		}
    		BaseLogUtils.newServiceLogger("importBatchTransfer===查询querypayNoList :" +JSONObject.toJSONString(querypayNoList)).info();
    		List<String> orginalPayNoList = Arrays.asList(paySchNoString.split(","));//Excel中支付表号
    		List<String> quePayNoList = Arrays.asList(querypayNoList.split(","));//移交列表查询支付表号
    		for(String payNo : orginalPayNoList){
				if(StringUtils.isNotBlank(payNo)){
					int tt=querypayNoList.indexOf(payNo);
					if(querypayNoList.indexOf(payNo)==-1) {//移交列表查不到此支付表号
						result.setSuccess(BaseConstant.IS_YESNO_NO);
			    		result.setInfo("未查到支付表："+payNo+"的数据，请核查");
			    		return result;
					}
				}
			}
    		for(String payNo : quePayNoList){
				if(StringUtils.isNotBlank(payNo)){
					int tt=paySchNoString.indexOf(payNo);
					int frIndex =paySchNoString.indexOf(payNo);
					int endIndex =paySchNoString.lastIndexOf(payNo,paySchNoString.length()+1);
					if(frIndex!=endIndex) {
						result.setSuccess(BaseConstant.IS_YESNO_NO);
			    		result.setInfo("支付表："+payNo+"数据重复，请核查");
			    		return result;
					}
				}
			}
    	}//end 比对结束
		for (int i = 0; i < list.size(); i++) {
    		ArcTransferMainVO trVo = list.get(i); 
    		if("0".equals(trVo.getTransferStatus()) &&  ("3".equals(trVo.getStorageStatus())
    				 || "4".equals(trVo.getStorageStatus()) ||  "3".equals(trVo.getEleStorageStatus()) 
    				 || "4".equals(trVo.getEleStorageStatus()))
    		  ){
    			if(StringUtils.isEmpty(transferType)) {//本次移交分类
    				if("S01".equals(trVo.getPrdStsCd()) || "S0103".equals(trVo.getPrdStsCd()) || "S0104".equals(trVo.getPrdStsCd())
        					|| "S0105".equals(trVo.getPrdStsCd())) {
        				transferType="1";
        			}else {
        				transferType="2";
        			}
    			}//
    			//比对第一次移交分类与当前遍历对象移交分类是否一致
    			String cuType="";
    			if("S01".equals(trVo.getPrdStsCd()) || "S0103".equals(trVo.getPrdStsCd()) || "S0104".equals(trVo.getPrdStsCd())
    					|| "S0105".equals(trVo.getPrdStsCd())) {
    				cuType="1";
    			}else {
    				cuType="2";
    			}
    			if(transferType.equals(cuType)) {
    				zpaySchNoString = zpaySchNoString+trVo.getPaySchId()+",";
    			}else {
    				notPassPaySchNoString2 = notPassPaySchNoString2 +trVo.getPaySchNo()+",";
    			}
    		}else {
    			notPassPaySchNoString = notPassPaySchNoString +trVo.getPaySchNo()+",";
    		}
		}
        BaseLogUtils.newServiceLogger("importBatchTransfer===最终校验支付表集合 zpaySchNoString:" +JSONObject.toJSONString(zpaySchNoString)).info();
        BaseLogUtils.newServiceLogger("importBatchTransfer===最终不合格支付表集合 notPassPaySchNoString:" +JSONObject.toJSONString(notPassPaySchNoString)+"notPassPaySchNoString2"+JSONObject.toJSONString(notPassPaySchNoString2)).info();
        if(StringUtils.isNotBlank(notPassPaySchNoString)){
        	result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("Excel表格中，支付表号："+notPassPaySchNoString+"不符合发起规则。请核查归档状态和移交状态！");
			return result;
        }
        if(StringUtils.isNotBlank(notPassPaySchNoString2)){
        	result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("Excel表格中，支付表号："+notPassPaySchNoString2+"不符合发起规则。移交分类不允许混选，请核查！！");
			return result;
        }
        if(StringUtils.isEmpty(zpaySchNoString)) {
        	result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("上传的EXCEL中支付表编号不允许为空，请核查!!!");
			return result;
        }
        zpaySchNoString = zpaySchNoString.substring(0,zpaySchNoString.lastIndexOf(","));
        session.removeAttribute("zpaySchNoString");
		session.setAttribute("zpaySchNoString", zpaySchNoString);
		result.setData(zpaySchNoString);
       return result;
	}
	/**
	 * 解析读取excel里的内容
	 * @param fis
	 * @param result
	 * @return
	 */
	public DataResultVO parseExcel(InputStream fis,DataResultVO result) throws Exception{
		String paySchCds = "";
		int num = 0;
		try {  
            HSSFWorkbook book = new HSSFWorkbook(fis);  
            HSSFSheet sheet = book.getSheetAt(0);
            int rowCount = sheet.getPhysicalNumberOfRows(); //获取总行数
            //判断一下，是否下载了模板
            HSSFCell cellT = sheet.getRow(0).getCell(0) ;
            String cellTValue = cellT.getStringCellValue().trim();
            if(StringUtils.isEmpty(cellTValue)) {
            	result.setSuccess(BaseConstant.IS_YESNO_NO);
    			result.setInfo("请下载模板，然后填写数据!");
    			return result;
            }
            if(!"*支付表号".equals(cellTValue)) {
            	result.setSuccess(BaseConstant.IS_YESNO_NO);
    			result.setInfo("请下载模板，然后填写数据!!!");
    			return result;
            }
            
            for(int i = 1; i < rowCount; i++) {//从第2行开始
            	HSSFCell cell = sheet.getRow(i).getCell(0) ;
            	cell.setCellType(1);
            	String cellValue = cell.getStringCellValue().trim();
            	cellValue.replace("\\s","");
            	cellValue.replace("\\n", "");//回车符号
            	cellValue.replace("\\t", "");//水平制表符
            	cellValue.replace("\\r", "");//换行符
            	if(StringUtils.isNotBlank(cellValue)){
            		if(num > 31){
            			 continue;//跳出循环
            		}
            		if("".equals(paySchCds)){
            			paySchCds =  "'" + cellValue + "'";
            		}else{
            			paySchCds += ",'" + cellValue + "'";
            		}
            		num++;
            	}
            }
		 } catch (IOException e) {
	        	result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo("请下载模板");
				BaseLogUtils.error(logger, "parseExcel", "错误[Exception] -ERROR:" +e.getMessage(), CurrentThreadContext.getCurrentUserName());
				e.getStackTrace();
				return result;
	     }catch(NullPointerException  e) {
		    	result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo("解析Excel出错，请删掉Excel中支付表号为空的数据行!");
				BaseLogUtils.error(logger, "parseExcel", "错误[Exception] -ERROR:" +e.getMessage(), CurrentThreadContext.getCurrentUserName());
				e.getStackTrace();
		 } 
		if(num>=31) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("一次最多支持30条数据发起，请核查Excel中支付表号数量!!");
			return result;
		}
		
		if(StringUtils.isEmpty(paySchCds)) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("上传的EXCEL中支付表编号不允许为空，请核查!");
			return result;
		}
		Map reMap = new HashMap();
		reMap.put("paySchCds", paySchCds);
		reMap.put("num", num);
        result.setData(reMap);
		BaseLogUtils.newServiceLogger("parseExcel===arr:" +JSONObject.toJSONString(paySchCds)).info();
        return result; 
	}
	
	
	
	
}

